Grokking the Coding Interview: Patterns for Coding Questions
Ask Author
Back to course home

0% completed

Vote For New Content
Valid Palindrome II (easy)
On this page

Problem Statement

Examples

Try it yourself

Problem Statement

Given string s, determine whether it's possible to make a given string palindrome by removing at most one character.

A palindrome is a word or phrase that reads the same backward as forward.

Examples

  1. Example 1:

    • Input: "racecar"
    • Expected Output: true
    • Justification: The string is already a palindrome, so no removals are needed.
  2. Example 2:

    • Input: "abccdba"
    • Expected Output: true
    • Justification: Removing the character 'd' forms the palindrome "abccba".
  3. Example 3:

    • Input: "abcdef"
    • Expected Output: false
    • Justification: No single character removal will make this string a palindrome.

Constraints:

  • 1 <= s.length <= 10<sup>5</sup>
  • str consists of lowercase English letters.

Try it yourself

Try solving this question here:

Python3
Python3

. . . .

.....

.....

.....

Like the course? Get enrolled and start learning!

On this page

Problem Statement

Examples

Try it yourself