Given an array A of size N. Print all the numbers less than K in the array. The numbers should be such that the difference between every adjacent digit should be 1.
Note: Print '-1' if no number if valid.
Input Format
The first line consists of an integer T i.e number of test cases. T testcases follow. Each testcase contains two lines of input. The first line consists of two integers N and K separated by a space. The next line consists of N spaced integers.
Constraints
1 <= T <= 100
1 <= N <= 10 5
1 <= K , A[i] <= 1018
Output Format
For each testcase, print the required output.
Sample Input 0
1
8 54
7 98 56 43 45 23 12 8
Sample Output 0
43 45 23 12
Sample Input 1
4
6 2000
123 234 245 121 456 677
5 123
121 101 10 111 123
5 50000
246 2344 455 4545 6756
3 12345
10 1234 4321
Sample Output 1
123 234 121 456
121 101 10
4545
10 1234 4321
Answers
Answered by
0
Answer:
Hope this helps! Do mark me the brainliest!
Explanation:
nput: A[] = {0, 1, 5}, N = 1, K = 2
Output: 2
Only valid numbers are 0 and 1.
Input: A[] = {0, 1, 2, 5}, N = 2, K = 21
Output: 5
10, 11, 12, 15 and 20 are the valid numbers.
Similar questions
Social Sciences,
5 hours ago
English,
10 hours ago
Computer Science,
10 hours ago
Physics,
8 months ago
Math,
8 months ago