Approach Summary
While left and right point to equal chars, advance left past duplicates and retreat right past duplicates until pointers cross.
How to Recognize This Pattern
- Delete all matching chars from both ends while they match
- Two pointers collapse from outside in
Complexity Analysis
Time Complexity
O(n)
Space Complexity
O(1)
Tags
String Two Pointers