Created
January 1, 2020 09:15
-
-
Save SuryaPratapK/79465ba65c9a412881536510dd558cd7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
using namespace std; | |
int main() { | |
int tc; | |
cin>>tc; | |
while(tc--) //test cases | |
{ | |
int N; | |
cin>>N; | |
//Input all N eleemnts | |
int arr[N]; | |
int repeating,missing; | |
bool present[N+1] = {false}; //Checks which numbers are present | |
for(int i=0;i<N;++i) | |
{ | |
cin>>arr[i]; | |
if(present[arr[i]]==true) | |
repeating = arr[i]; | |
present[arr[i]] = true; | |
} | |
for(int i=1;i<=N;++i) | |
{ | |
if(present[i]==false) | |
{ | |
missing = i; | |
break; | |
} | |
} | |
cout<<repeating<<" "<<missing<<"\n"; | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
All test cases not pass 😥
@rkadam61001