FastPrepValid Palindrome

Valid Palindrome

The Walt Disney Company logoThe Walt Disney Company● EasyFULLTIMEOAPHONE SCREEN

Problem statement

Return whether s reads the same forward and backward after ignoring all characters except ASCII letters and digits and treating uppercase and lowercase letters as equal.

The empty string and a string with no letters or digits are palindromes.

Function

isPalindrome(s: String) → boolean

Examples

Example 1

s = "Was it a car or a cat I saw?"return = true

Ignoring spaces, punctuation and letter case gives wasitacaroracatisaw, which reads the same in both directions. Return true.

Example 2

s = "0P"return = false

The normalized characters are 0 and p. They differ, so return false.

Constraints

  • 0 <= s.length <= 500
  • Every character is printable ASCII, with a code from 32 through 126.

More The Walt Disney Company problems

See The Walt Disney Company hiring insights
Saved
public boolean isPalindrome(String s) {
    // Write your code here
}
Checking account…