---
# System prepended metadata

title: 0246. Strobogrammatic Number
tags: [Leetcode, FaceBook, Easy]

---

# 0246. Strobogrammatic Number
###### tags: `Leetcode` `Easy` `FaceBook`
Link: https://leetcode.com/problems/strobogrammatic-number/
## 思路 O(N) O(1)
Map.of()的用法：
- 参数为一个key，一个value... 最多十个pairs
- 建完之后map entry是不能更改的
## Code
```java=
class Solution {
    public boolean isStrobogrammatic(String num) {
        Map<Character, Character> rotatedDigits = new HashMap<>(
            Map.of('0','0','1','1','6','9','8','8','9','6'));
        
        int left = 0;
        int right = num.length()-1;
        while(left<=right){
            char leftChar = num.charAt(left);
            char rightChar = num.charAt(right);
            if(!rotatedDigits.containsKey(leftChar)||rightChar!=rotatedDigits.get(leftChar)){
                return false;
            }
            left++;
            right--;
        }
        return true;
    }
}
```