Numbers with one absolute difference
Submissions: 2399   Accuracy:

18.68%

  Difficulty: Hard   Marks: 8

Given a number N. The task is to print all the numbers less than or equal to N in increasing order, with the fact that absolute difference between any adjacent digits of number should be 1.

Input:
The first line of input contains an integer T denoting the number of test cases. Then T test cases follow. Each test case contains an integer N.

Output:
In new line print all the required numbers. if there is no such number less than or equal to N then print "-1".

Constraints:
1<=T<=100
1<=N<=1012

Example:
Input:

2
20
9
Output:
10 12
-1

** For More Input/Output Examples Use 'Expected Output' option **

Contributor: Arun tyagi
Author: arun03


If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.



Need help with your code? Please use ide.geeksforgeeks.org, generate link and share the link here.

to report an issue on this page.