Valid Palindrome
Valid Palindrome
Keep the Unicode letters and decimal digits in s, in their original order. Compare the retained code points from both ends using Unicode simple lowercase (one code point per letter). Return true if every pair matches. An empty sequence or a single retained character passes.
Function signature
func IsValidPalindrome(s string) bool
In Python, implement is_valid_palindrome(s).
Example
"A man, a plan, a canal: Panama" -> true
"race a car" -> false
" " -> true
"É,é" -> true
"²a" -> true
"İi" -> true
Constraints
- The UTF-8 encoding of s is at most 200,000 bytes
Superscript ² falls outside the decimal-digit category. A combining mark is skipped as its own code point. Compare without accent normalization or multi-character case folding. Aim for linear time.
Try it before coding
Trace "3-é,É-3" and "3-é,É-4". Which retained pair determines the result of the second input?
Check your reasoning
The first input retains 3, é, é, 3 and passes. The second fails immediately on 3 and 4.
Run tests to see results
No issues detected