Given an array arr[] of N numbers. The task is to print only those numbers whose digits are from set {1,2,3}.
Input:
The first line of input contains an integer T denoting the number of test cases. Then T test cases follow. Each test case consists of two lines. First line of each test case contains an integer N and the second line contains N space separated array elements.
Output:
For each test case, In new line print the required elements in increasing order. if there is no such element present in the array print "-1".
Constraints:
1 <= T <= 100
1 <= N <= 106
1 <= A[i] <= 106
Example:
Input:
3
3
4 6 7
4
1 2 3 4
5
12 111 34 13 55
Output:
-1
1 2 3
12 13 111
Explanation:
Testcase 1: No elements are there in the array which contains digits 1, 2 or 3.
Testcase 2: 1, 2 and 3 are the only elements in the array which conatins digits as 1, 2 or 3.
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.
preparecodinginterview_dot_com | 190 |
__murugan__ | 173 |
manvimahajan20 | 140 |
xiaoyan_yunche | 139 |
ShameekAgarwal | 116 |
preparecodinginterview_dot_com | 190 |
__murugan__ | 173 |
manvimahajan20 | 166 |
SoumyaKaushik | 146 |
arpit_anshuman | 140 |
blackshadows | 5331 |
Ibrahim Nash | 5219 |
akhayrutdinov | 5111 |
mb1973 | 4929 |
Quandray | 4567 |