Problem Submissions Solution

Stepping Numbers

Difficulty: Medium

Acceptance: %

Points: 30.00

A number is considered a stepping number if the absolute difference between every two consecutive digits is exactly 1. For example, '321' is a stepping number, but '421' is not. Given two integers n and m, your task is to find the total count of all stepping numbers in the range [n, m].

Your task is to complete the function steppingNumbers() which takes the integer n and integer m as input parameters and returns the number of stepping numbers in the range between n and m.

Topics

Companies

Articles

Examples:

Expected Time Complexity: O(log(M))

Expected Auxiliary Space: O(SN) where SN is the number of stepping numbers in the range

Constraints:
  • 0 = N < M = 10^7
Companies:
Amazon
Topics:
BFS DFS
Locked Content
Access Restricted: Please Login to access the code editor and test cases.