Geeksforgeeks Solution For Two Repeated Elements

Problem:- You are given an array of N+2 integer elements. All elements of the array are in range 1 to N. And all elements occur once except two numbers which occur twice. Find the two repeating numbers.


The first line of the input contains an integer T, denoting the total number of test cases. Then T test cases follow Each test case consists of two lines. The first line of each test case contains an integer N denoting the range of numbers to be inserted in an array of size N+2. The second line of each test case contains the N+2 space separated integers denoting the array elements.


Print the two elements occurring twice in the array. Order of the two elements must be preserved as in the original list, i.e., print the element which arrives first(2nd time).


1 ≤ T ≤ 30
1 ≤ N ≤ 100



1 2 1 3 4 3


1 3

Submit Your Solution:- Click Here


using namespace std;
int main()
int t;
   int n;
   int a[n+2],b[n+2]={};

   for(int i=0;i<n+2;i++)
           cout<<a[i]<<" ";
return 0;


Geeksforgeeks Solution For Two Repeated Elements

Ghanendra Yadav

Ghanendra Yadav

Hello, I Am Ghanendra Yadav Owner of This Blog, I am professional Blogger and Programmer. I Love Programming, Logo Making, And Banner Designing. My Highest Qualification is MCA From NIT Warangal. You Can Find Me On Social Media Through Below Link And If You Have Any Query Related To Programming And Other Subject Comment Below or You Can Mail Me I Will Try To Answer Within 24 Hours Email:- yghanendra@student.nitw.ac.in

Find me on Social Media

Facebook | Twitter | Google+ | RSS Feed

No comments:

Post a Comment