622. Mayank Bhaiya's Magic Numbers
0
Medium
Mayank Bhaiya is fascinated by numbers that have the same difference between every two consecutive digits. He needs your help to find all such numbers.
Given two integers N and k, you are required to print an array of all integers of length N where the difference between every two consecutive digits is k. The array should be printed in sorted order. Please note that the integers should not have leading zeros, so numbers like 02 and 043 are not allowed.
Given two integers N and k, you are required to print an array of all integers of length N where the difference between every two consecutive digits is k. The array should be printed in sorted order. Please note that the integers should not have leading zeros, so numbers like 02 and 043 are not allowed.
Input Format
The first line contains two space-separated integers N and K.
Output Format
Print the desired output array.
Example
Input
3 7
Output
181 292 707 818 929
Constraints
2 <= N <= 9
0<= k <= 9
0<= k <= 9
Loading...
View Submissions
Console