Evaluate Reverse Polish Notation @ LeetCode (Python)
Sort Colors @ LeetCode (Python)

Valid Palindrome @ LeetCode (Python)

kitt posted @ 2014年3月01日 21:12 in LeetCode , 2191 阅读

 

class Solution:
    # @param s, a string
    # @return a boolean
    def isPalindrome(self, s):
        newS = []
        for i in s:
            if '0' <= i <= '9' or 'a' <= i <= 'z': newS.append(i)
            elif 'A' <= i <= 'Z': newS.append(chr(ord(i) - ord('A') + ord('a')))
        return newS == newS[::-1]

登录 *


loading captcha image...
(输入验证码)
or Ctrl+Enter