leetcode_246
Solutions
class Solution {
public:
unordered_map<char, char> m = {{'6', '9'}, {'9', '6'}, {'1', '1'}, {'0', '0'}, {'8', '8'}};
bool isStrobogrammatic(string num) {
string num1(num.rbegin(), num.rend());
for (auto & n : num1) {
if (m.count(n))
n = m[n];
else
n = '*';
}
return num1 == num;
}
};Last updated