Skip to content

Instantly share code, notes, and snippets.

@arjunsk
Last active December 15, 2016 05:18
Show Gist options
  • Save arjunsk/78d44af6f89a269976299b789c77e038 to your computer and use it in GitHub Desktop.
Save arjunsk/78d44af6f89a269976299b789c77e038 to your computer and use it in GitHub Desktop.
CODEKAT HUNTER SET1
/** Coded By Xvamp999 **/
#include <bits/stdc++.h>
using namespace std;
unsigned long long mod=1000000007;
int main(){
int n;
cin>>n;
set<string> reg_nos;
string reg_no;
set<string> dups;
for(int i=0;i<n;i++){
cin>>reg_no;
// Convert registration number to lower case
transform(reg_no.begin(),reg_no.end(),reg_no.begin(),::tolower);
if(reg_nos.count(reg_no)!=0){
dups.insert(reg_no);
}else{
reg_nos.insert(reg_no);
}
}
for(auto itr=dups.begin();itr!=dups.end();itr++){
cout<< *itr <<endl;
}
return 0;
}
/** Coded By Xvamp999 **/
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fir first
#define sec second
#define pi acos(-1)
#define ll long long
using namespace std;
unsigned long long mod=1000000007;
int main(){
int n;
cin>>n;
int arr[n];
for(int i=0;i<n;i++)
cin>>arr[i];
// Question find "an" integer where arr[i]==i
// Given array is sorted and distinct
for(int i=0;i<n;i++){
if(arr[i]<0) // i cant be -ve
continue;
else if(arr[i]==i){
cout<<i;
break;
}
else if(arr[i] > i ){ // if arr[i]>i then there is no way that, the following numbers can hold the condition arr[i]==i
// as they are distinct and sorted
cout<<"Nil"<<endl;
break;
}
}
return 0;
}
/** Coded By Xvamp999 **/
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fir first
#define sec second
#define pi acos(-1)
#define ll long long
using namespace std;
unsigned long long mod=1000000007;
int main(){
int n;
cin>>n;
int arr[n];
for(int i=0;i<n;i++)
cin>>arr[i];
//Using property of XOR's
int ans=arr[0];
for(int i=1;i<n;i++)
ans= ans ^ arr[i];
cout<<ans;
return 0;
}
/** Coded By Xvamp999 **/
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fir first
#define sec second
#define pi acos(-1)
#define ll long long
using namespace std;
unsigned long long mod=1000000007;
int main(){
int n;
cin>>n;
int arr[n];
set<int> set1;
bool flag=false;
int ans;
for(int i=0;i<n;i++){
cin>>arr[i];
if(set1.count(arr[i]) == 0 )
set1.insert(arr[i]);
else if(flag==false && set1.count(arr[i]) !=0 ){
flag=true;
ans=arr[i];
}
}
cout<<ans;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment