|All-time Popular Problems|
|Sort a stack|
|Delete Middle of Linked List|
|BFS traversal of graph|
|Largest subarray of 0's and 1's|
|Immediate Smaller Element|
|Delete nodes having greater value on right|
|Node at a given index in linked list|
|Two numbers with sum closest to zero|
|Print all nodes that don’t have sibling|
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).
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.
Print the duplicate elements from the array.The order of the output should be as the element found to be repeated.
0 3 1 2
2 3 1 2 3