Dodomeki
Sign in

10. Valid Palindrome

Easy

Given a string texto, determine whether it is a palindrome when letters and numbers are compared case-insensitively. Ignore spaces, punctuation, and any other character that is not a letter or number. Return true or false.

Example 1
Input: texto = "Socorram-me, subi no ônibus em Marrocos!"
Output: true
Explanation: Ignoring punctuation and spaces, the sequence read from both ends is the same.
Example 2
Input: texto = "Mocka 2026"
Output: false
Constraints
  • 0 <= texto.length <= 10^5
  • O texto contém caracteres ASCII.
StringsTwo pointers
Caso 1
texto =
"A man, a plan, a canal: Panama"
Expected =
true
Caso 2
texto =
"Mocka 2026"
Expected =
false

Run checks these 2 cases. Submit runs all 7, including hidden ones.