class Solution(object):
def isStrobogrammatic(self, num):
"""
:type num: str
:rtype: bool
"""
maps = {("0","0"),("1","1"),("8","8"),("6","9"),("9","6")}
i, j = 0, len(num)-1
while i<=j:
if (num[i], num[j]) not in maps:
return False
i += 1
j -= 1
return True
1 map用大括号,里面可以是一对一对的element
2 使用双指针,从头和尾往中间扫,只要没在map里面,就返回False,直到遍历完全