Duplicate Elements
Submissions: 863   Accuracy:

21.35%

  Difficulty: Easy   Marks: 2
Associated Course(s):   Fork Java

You are given an array A of size N. The array contains almost distinct elements with some duplicated. You have to print the elements in sorted order which appears more than once.

Input Format:
The first line of input contains T, denoting the number of testcases. T testcases follow. Each testcase contains two lines of input.  The first line of input contains size of array N. The second line contains N integers separated by spaces.

Output Format:
For each test case, in a new line, print the required answer. If there are no duplicates print -1.

Your Task:
Your task is to complete the function SortedDuplicates(arr, n) which accepts array and its size as an argument.

Constraints:
1 <= T <= 100
1 <= N <= 100
1 <= Ai <= 106

Examples:
Input:

1
9
3 4 5 7 8 1 2 1 3

Output:
1 3

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

Author: Soul_xhacker


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.



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


to report an issue on this page.