Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Solution {
- public:
- bool isStrobogrammatic(string num) {
- unordered_map<int, int> m;
- int n = num.size();
- m[1] = 1; m[0] = 0, m[6] = 9, m[8] = 8, m[9] = 6;
- for(int i=0, j=n-1; i<=j; i++, j--){
- int d = num[i]-'0';
- int d1 = num[j]-'0';
- if(!m.count(d) || m[d] != d1) return false;
- }
- return true;
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement