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/009_Palindrome_Number.py at master · germanheinz/leetcode Expand file tree/ Copy path009_Palindrome_Number.pyMore file actions 67 lines (58 loc) · 1.55 KB / Copy path009_Palindrome_Number.pyFile metadata and controls67 lines (58 loc) · 1.55 KB 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 # class Solution(object): # def isPalindrome(self, x): # """ # :type x: int # :rtype: bool # """ class Solution(object): def isPalindrome(self, x: int) -> bool: x = str(x) if (x == x[::-1]): return True return False # def isPalindrome(self, x): # if x < 0: # return False # ls = len(str(x)) # tmp = x # for i in range(int(ls/2)): # right = int(tmp % 10) # left = tmp / (10 ** (ls - 2 * i - 1)) # left = int(left % 10) # if left != right: # return False # tmp = tmp // 10 # return True # def isPalindrome(self, x): # #leetcode book # if x < 0: # return False # div = 1 # while x / div >= 10: # div *= 10 # while x != 0: # left = x / div # right = x % 10 # if left != right: # return False # x = (x % div) / 10 # div /= 100 # return True # def isPalindrome(self, x): # # reverse number # if x < 0: # return False # rev_x = 0 # temp = x # while temp != 0: # curr = temp % 10 # rev_x = rev_x * 10 + curr # temp = temp // 10 # if rev_x == x: # return True # else: # return False if __name__ == '__main__': # begin s = Solution() print s.isPalindrome(1001) |
| 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. |