Skip to content

Practice Count Stepping Numbers in Range

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Hard#2801
LeetCode Problem

Count Stepping Numbers in Range

Problem Statement

Given two positive integers low and high represented as strings, find the count of stepping numbers in the inclusive range [low, high]. A stepping number is an integer such that all of its adjacent digits have an absolute difference of exactly 1. Return an integer denoting the count of stepping numbers in the inclusive range [low, high]. Since the answer may be very large, return it modulo 10^9 + 7. Note: A stepping number should not have a leading zero.

Source: Count Stepping Numbers in Range on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
low = "1", high = "11"
Output
10

# Example 2

Input
low = "90", high = "101"
Output
2

Constraints

1 <= int(low) <= int(high) < 10^100
1 <= low.length, high.length <= 100
low and high consist of only digits.
low and high don't have any leading zeros.

Related LeetCode Problems

Practice more problems similar to Count Stepping Numbers in Range.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.