GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — leetcode/python/246_Strobogrammatic_Number.py at master · qiyuangong/leetcode

Expand file tree

/

246_Strobogrammatic_Number.py

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
21 lines (19 loc) · 634 Bytes
/

246_Strobogrammatic_Number.py

Copy path

File metadata and controls

21 lines (19 loc) · 634 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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.