Easy · Two Pointers
Understand → Visualise → Practice.
A palindrome reads the same forwards and backwards. You can check one without building a cleaned-up copy.
Walk two pointers towards each other, skipping characters that don't count, and compare as you go.
Move past spaces and punctuation.
'T' and 't' count as equal.
One mismatch means it is not a palindrome.
O(n) time, O(1) extra space.
Digits count as characters. Only letters and digits are compared.
Read the full guides first: Big-O and Complexity, Arrays and Dynamic Arrays, Prefix Sums and Difference Arrays.
Guest mode lets you understand, visualise and run the sample tests. Create a free account to submit and save your solutions.