Practice Count Numbers with Non-Decreasing Digits
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 two integers, l and r, represented as strings, and an integer b. Return the count of integers in the inclusive range [l, r] whose digits are in non-decreasing order when represented in base b. An integer is considered to have non-decreasing digits if, when read from left to right (from the most significant digit to the least significant digit), each digit is greater than or equal to the previous one. Since the answer may be too large, return it modulo 10^9 + 7.
Source: Count Numbers with Non-Decreasing Digits on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
l = "23", r = "28", b = 8
3
# Example 2
l = "2", r = "7", b = 2
2
Constraints
Related LeetCode Problems
Practice more problems similar to Count Numbers with Non-Decreasing Digits .
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.