617. Stepping Numbers
A stepping number is a number where adjacent digits have a difference of exactly 1.
For example, 123 is a stepping number ( |1-2| = 1 and |2-3| = 1 ), but 349 is not.
Given two integers low and high , return all stepping numbers in the inclusive range [low, high], sorted in increasing order.
Example 1:
Input: low=0, high=21
Output: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 21]
Explanation:
All single-digit numbers are stepping numbers and 10, 12, and 21 are stepping numbers.
Example 2:
Input: low=10, high=100
Output: [10, 12, 21, 23, 32, 34, 43, 45, 54, 56, 65, 67, 76, 78, 87, 89, 98]
Explanation:
The numbers satisfy the stepping number condition within [10, 100]
Now Your Turn!
Pick the correct output for the given inputInput: low=100, high=500
Still unsure what the problem is asking ?
Let’s go through a few more examples, step by step, to make it clearer.
Constraints:
- 0 <= low <= high <= 2 * 109