Thoughts On Palindrome Algorithms

Travis Lee
1 min readJul 22, 2021

by Travis Scott Lee

I have been working on algorithms on Leetcode lately. I found myself struggling to come up with concepts on how to tackle such palindrome algorithms. A palindrome is a word, phrase, or sequence that reads the same backward as forward, like racecar.

Some ideas I came up with are the following:

  1. When the palindrome is an array, make a copy of the original array so that we do not mutate the original array. Then scan from outside to inside to find the palindrome by iterating through the array of items.
  2. When the palindrome is just a string and to keep it inline with Big O, I should start with the first index of the string and scan outward. If there’s no palindrome, repeat with the second index of the string, and so on and forth.

These ideas are not perfect, but if anyone has any ideas. Just leave a comment!

--

--