Numbers Steppers

MATH

Problem

Given two integers low and high, return a list of all the Stepping Numbers in the range [low, high] inclusive. A Stepping Number is defined as a number where the adjacent digits have a difference of exactly 1.

For example, 123 is a Stepping Number (as 2-1=1 and 3-2=1), while 358 is not (as 5-3=2 and 8-5=3).

Examples

steppingNumbers(10, 15) // returns [10, 12] /* The Stepping Numbers between 10 and 15 are 10 and 12, as they are the numbers in this range where adjacent digits differ by 1. */ steppingNumbers(15, 30) // returns [21] /* The only Stepping Number between 15 and 30 is 21, where adjacent digits differ by 1. */
Loading...