Skip to content

Instantly share code, notes, and snippets.

@SuryaPratapK
Created January 1, 2020 09:15
Show Gist options
  • Save SuryaPratapK/79465ba65c9a412881536510dd558cd7 to your computer and use it in GitHub Desktop.
Save SuryaPratapK/79465ba65c9a412881536510dd558cd7 to your computer and use it in GitHub Desktop.
#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;
}
@tamilvanan31
Copy link

This solution is not working and I don't know why. Any changes to this solution.

@rkadam61001
Copy link

@tamilvanan31 it's working fine for me!!

Copy link

ghost commented Mar 30, 2022

All test cases not pass 😥
@rkadam61001

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment