GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — leetcode/python/246_Strobogrammatic_Number.py at master · qiyuangong/leetcode Expand file tree/ Copy path246_Strobogrammatic_Number.pyMore file actions 21 lines (19 loc) · 634 Bytes / Copy path246_Strobogrammatic_Number.pyFile metadata and controls21 lines (19 loc) · 634 Bytes 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 class Solution(object): def isStrobogrammatic(self, num): """ :type num: str :rtype: bool """ # hash table dic = {'0':'0', '6':'9', '9': '6', '1' :'1', '8': '8'} temp_s = '' for c in num[::-1]: if c not in dic: return False temp_s += dic[c] if int(temp_s) == int(num): return True return False # def isStrobogrammatic(self, num): # # https://discuss.leetcode.com/topic/20840/1-liners-python # return all(num[i] + num[~i] in '696 00 11 88' for i in range(len(num)/2+1)) |
| You are visitor 01402792 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |