摘要: 1 class Solution: 2 # @return an integer 3 def reverse(self, x): 4 if x < 0 : 5 a = str(x) 6 a = filter(str.isdigit,a) 7 a = a[::-1] 8 b = int(a) 9 b = 0 - b10 else :11 a = str(x)12 a = filte... 阅读全文
posted @ 2014-03-23 18:01 laste 阅读(74) 评论(0) 推荐(0)
摘要: 1 class Solution: 2 # @param s, a string 3 # @return a string 4 def reverseWords(self, s): 5 s = s.rstrip().lstrip() 6 d = s.split(' ') 7 e = d[::-1] 8 f = " ".join(e) 9 f = " ".join(f.split())10 return f 阅读全文
posted @ 2014-03-22 22:06 laste 阅读(95) 评论(0) 推荐(0)
摘要: 1 class Solution: 2 # @param s, a string 3 # @return a boolean 4 def isPalindrome(self, s): 5 d = filter(str.isalnum, s) 6 c = d[::-1] 7 if c.upper() == d.upper() : 8 return True 9 else :10 return False 阅读全文
posted @ 2014-03-21 20:07 laste 阅读(98) 评论(0) 推荐(0)