Skip to content

Palindromes

Coding Patterns: Palindromes (DP)

# 0(n) time | O(1) space - where n = len(string)
def isPalindrome(string):

    left = 0
    right = len(string) - 1
    while left <= right:
        if string[left] != string[right]:
            return False

        left += 1
        right -= 1

    return True


Find the original version of this page (with additional content) on Notion here.



Last update: November 20, 2021 07:19:02
Created: November 20, 2021 07:19:02
Authors: paulonteri (72.22%), Not Committed Yet (27.78%)