What is a palindrome?

A Palindrome is a word, phrase, or sequence that reads the same backward as forward.

Why do developers need to know what a palindrome is, and why should they learn this?

  • Palindromes are a commonly asked string manipulation / algorithm problem
  • The example below is the easiest one.
  • There are tons of palindrome questions ranging from easy to hard (see links at the end).
image-5

A Quick Palindrome Checking Method:

def reverse(s):
    return s[::-1]

def isPalindrome(s):
    rev = reverse(s)

    if (s == rev):
        return True
    return False

#
s = "racecar"
ans = isPalindrome(s)

if ans == 1:
    print("Yes")
else:
    print("No")

Source: https://www.geeksforgeeks.org/python-program-check-string-palindrome-not/

Quicker Palindrome Check:

str(n) == str(n)[::-1]

Source: https://stackoverflow.com/questions/17331290/how-to-check-for-palindrome-using-python-logic/17331328

Learning materials

Wikipedia: https://en.wikipedia.org/wiki/Palindrome

GeeksForGeeks: https://www.geeksforgeeks.org/string-palindrome/

Solve palindrome challenges

Leetcode: https://leetcode.com/problemset/all/?search=palindrome

Codewars: https://www.codewars.com/kata/search/my-languages?q=palindrome&beta=false

Other visualizations

Bubble Sort