BETA

Difficulty Level:

Basic

Total Submissions: 466 Accuracy:

18.88%

[Absolute Difference of 1]
     

Given an array.Print all numbers less than k in the array, with the fact that absolute difference between any adjacent digits should be 1.

Note: Print '-1' if no number if valid.

Input:
The first line consists of an integer T i.e number of test cases. The first line of each test case consists of two integers n and k.The next line consists of n spaced integers. 

Output:
Print the required output.

Constraints: 
1<=T<=100
1<=n<=103
1<=k,a[i]<=104

Example:
Input:

2
8 54
7 98 56 43 45 23 12 8
10 1000
87 89 45 235 465 765 123 987 499 655

Output:
7 43 45 23 12 8 
87 89 45 765 123 987 

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

Contributor: Saksham Ashtputre

Set Default Code

					   
It is recommended to 'Compile & Test' your code before clicking 'Submit'!

Compilation/Execution Result:

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