Problem · String

Valid Palindrome II

Learn this problem
EasyBloomberg logoBloombergFULLTIMEPHONE SCREEN

Problem statement

Given a string s, return true if it can become a palindrome after deleting at most one character. Otherwise, return false.

Function

validPalindrome(s: String) → boolean

Examples

Example 1

s = "aba"return = true

The string is already a palindrome, so no deletion is needed.

Example 2

s = "abca"return = true

Deleting b or c leaves a palindrome.

Constraints

  • 1 <= s.length <= 10^5
  • s contains only lowercase English letters.

More Bloomberg problems

drafts saved locally
public boolean validPalindrome(String s) {
    // write your code here
}
s"aba"
expectedtrue
checking account