-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path271A.cpp
More file actions
26 lines (24 loc) · 715 Bytes
/
271A.cpp
File metadata and controls
26 lines (24 loc) · 715 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#include<bits/stdc++.h>
using namespace std;
void digit_finder(int x , unordered_map<int , int> &duplicate_check){
if(x == 0){
return ;
}
int digit = x%10;
duplicate_check[digit]++;
digit_finder(x / 10 ,duplicate_check);
}
//basic idea is that since there are only 4 unique digits in our number so the size of the hashmap must be 4!!!
int main(){
int n;
cin>>n;
int x;
for(x = n+1 ; x <= 90000 ;x++){
unordered_map<int , int>duplicate_check;
digit_finder(x , duplicate_check);
if(duplicate_check.size() == 4){// the x which has 4 sized hashmap is stored and then printed
break;
}
}
cout<<x;
}