题目:788. 旋转数字(力扣788)
class Solution {
public:
int rotatedDigits(int n) {
int res = 0;
for(int i=1; i<n+1; ++i){
int cur = i;
bool flag = false;
while(cur!=0){
if(mp.find(cur%10) == mp.end()){
goto a;
}
if(mp[cur%10] != cur%10){
flag = true;
}
cur /=10;
}
if(flag) res++;
a:;
}
return res;
}
private:
unordered_map<int,int> mp = {{0,0},{1,1},{8,8},{2,5},{5,2},{6,9},{9,6}};
};