BETA

Difficulty Level:

Easy

Total Submissions: 4180 Accuracy:

8.71%

Find duplicates in an array (Function Problem)
     

Given an array A[], Your task is to complete the function printDuplicates which prints the duplicate elements of the given array. If no duplicate element is found  print -1.

Note: Auxiliary Space must be O(1) and Time complexity must be O(n).


Input:
The first line of input contains an integer T denoting the no of test cases. Then T test cases follow. Each test case contains an integer N which denotes number of elements of Array. Second line of each test case contains N space separated integers denoting elements of Array A[].


Output:
Print the duplicate elements from the array.


Constraints:
1<=T<=100
1<=N<=50
0<=A[]<=N


Example:
Input:
2
4
0 3 1 2
5
2 3 1 2 3 
Output:
-1
2 3 

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

Contributor: Saksham Raj Seth


					   
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.