Stepping Numbers

Medium

Given two numbers begin and end, find all the stepping numbers in the range [begin, end].

A positive integer is called a stepping number if the adjacent digits have a difference of 1. All single-digit numbers are stepping numbers.

123, 121, 654, 5 are all stepping numbers. 124, 122, 46 are not stepping numbers.

Example:
begin: 8
end: 15
stepping numbers: [8, 9, 10, 12]

Testing

Input Format

The first line contains an integer ‘T’ denoting the number of test cases.

For each test case the input has a line with two space-separated integers begin and end.

Output Format

For each test case, the output has a line with space-separated integers, denoting the stepping numbers.

Sample Input

3
8 15
11 11
10 10

Expected Output

8 9 10 12

10

Constraints

1 <= T <= 100
1 <= begin <= end <= 108

Companies
Editorial Link: Editorial