Skip to main content

Exercise 6: Almost Palindrome

A palindrome is a series of characters which is the same spelled forward and in reverse. For the purpose of this exercise, a capital letter is equal to its lowercase equivalent. Given a string, return whether or not the string would be a palindrome if one or fewer characters were removed. Return true if it is a palindrome or almost a palindrome, and false otherwise.

Input: 'Stop Pots'
Output: true
Explanation: This is a palindrome without modification.

Input: 'Madam, I am Adam.'
Output: false
Explanation: This is not a palindrome due to punctuation.

Input: 'CuteTuck'
Output: true
Explanation: Removing 'k' makes this string a palindrome.

Sketch:

Script: