Practice Count the Number of Powerful Integers
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Problem Statement
You are given three integers start, finish, and limit. You are also given a 0-indexed string s representing a positive integer. A positive integer x is called powerful if it ends with s (in other words, s is a suffix of x) and each digit in x is at most limit. Return the total number of powerful integers in the range [start..finish]. A string x is a suffix of a string y if and only if x is a substring of y that starts from some index (including 0) in y and extends to the index y.length - 1. For example, 25 is a suffix of 5125 whereas 512 is not.
Source: Count the Number of Powerful Integers on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
start = 1, finish = 6000, limit = 4, s = "124"
5
# Example 2
start = 15, finish = 215, limit = 6, s = "10"
2
# Example 3
start = 1000, finish = 2000, limit = 4, s = "3000"
0
Constraints
Related LeetCode Problems
Practice more problems similar to Count the Number of Powerful Integers.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.