Valid Palindrome

Problem Given a string, determine whether it is a palindrome — reads the same forwards and backwards. (Clarify the variant: raw comparison, or the LC-125 form that ignores case and non-alphanumeric characters.)

Input / Output

  • Input: string s.
  • Output: boolean.

Constraints

  • |s| up to 2*10^5; O(n) time, O(1) space — no reversed-copy allocation in the ideal answer.

Example

  • "A man, a plan, a canal: Panama" → true (alphanumeric, case-insensitive variant).
  • "race a car" → false.
asked …
LeaderboardSalaryAccount