Jumping Numbers (Contest)
Jumping Numbers easy Time Limit: 2 sec Memory Limit: 128000 kB
Last updated
Jumping Numbers easy Time Limit: 2 sec Memory Limit: 128000 kB
Last updated
Problem Statement :
Given a positive number X. Find all Jumping Numbers smaller than or equal to X. Jumping Number: A number is called Jumping Number if all adjacent digits in it differ by only 1. All single-digit numbers are considered as Jumping Numbers. For example 7, 8987 and 4343456 are Jumping numbers but 796 and 89098 are not. Input The first line of the input contains T denoting the number of test cases. Each test case contains a positive number N.
Constraints: 1 <= T <= 50 1 <= N <= 10^8 Output For each test case, print a single line containing all the Jumping numbers less than or equal to N from 1 in increasing order Example Sample Input: 2 10 50
Sample Output: 1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10 12 21 23 32 34 43 45
Explanation: Testcase 2: Here, the most significant digits of each jumping number is following increasing order, i.e., jumping numbers starting from 0, followed by 1, then 2 and so on, themselves being in increasing order 2, 21, 23.
link: