Skip to content

Instantly share code, notes, and snippets.

@vipul43
Created July 20, 2020 10:21
Show Gist options
  • Save vipul43/1087056fc73572c7af0cbb8329ec3882 to your computer and use it in GitHub Desktop.
Save vipul43/1087056fc73572c7af0cbb8329ec3882 to your computer and use it in GitHub Desktop.
cses day1 problems solutions
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;
void solution(){
int n;
cin >> n;
int arr[n-1];
for(int i=0; i<n-1; i++){
cin >> arr[i];
}
sort(arr, arr+(n-1));
bool flag = true;
for(int i=0; i<n-1; i++){
if(i+1!=arr[i]){
cout << i+1 << endl;
flag = false;
break;
}
}
if(flag){
cout << n << endl;
}
}
int main() {
int T=1;
// cin >> T;
for(int t=0; t<T; t++) {
solution();
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment