Problem
FAANG · LeetCode #125

Valid Palindrome — three-stage drill

1The ProblemEasy

Valid Palindrome

Reads the same forwards and backwards (letters & digits only).

INPUT s ="A man, a plan, a canal: Panama"strip non-alphanumeric, lowercaseamanaplanacanalpanamaleft halfright half (reversed)pivotmirror matchreturntrue
Examples
"racecar"→ true"race a car"→ false
2The PatternTIME O(n) · SPACE O(1)

Two Pointers

Converging from both ends, comparing as they meet.

loop while left < right · move both inwarda0b1c2d3e4f5g6left›right‹compare → if equal, move both inward
Problems using this pattern
3The SolutionRESULT → true

Step through it

r0a1c2e3c4a5r6leftright
Initialize: left at 0, right at 6.
Step 1 / 5
Arrow keys to navigate · escape to reset

All problems by pattern

Backtracking

Recursive Descent