Thursday, 6 April 2017

Geeksforgeeks Solution For " Two Repeated Elements "

GeeksforGeeks Solution For Hard Domain .Below You Can Find The Solution Of  School Basic ,Easy ,Medium . Or Hackerrank Solution You Can Also Direct Submit Your Solution to Geeksforgeeks Same Problem .You Need to login then you can submit you answers 

Problem :- Two Repeated Elements

Submit Your Solution :- Click Here 

Solution :- 

#include<iostream>
using namespace std;
int main()
{
int t;
cin>>t;
while(t--){
   int n;
   cin>>n;
   int a[n+2],b[n+2]={};

   for(int i=0;i<n+2;i++){
       cin>>a[i];
       b[a[i]]=b[a[i]]+1;
       if(b[a[i]]==2)
           cout<<a[i]<<" ";
   }
   cout<<endl;
}
return 0;
}

Output:-



Geeksforgeeks Solution For " Two Repeated Elements "

No comments:
Write comments

Recommended Posts × +