Palindrome

class Solution:
    # @param s, a string
    # @return a list of lists of string
    def isPalind(self, s):
        start, end = 0, len(s) - 1
        while start < end:
            if s[start] != s[end]:
                return False
            start += 1
            end -= 1
        return True

    def isPalindrome(self, s):
        for i in range(len(s)):
            if s[i] != s[len(s)-1-i]: return False
        return True

Last updated

Was this helpful?