Left / Right Heads
Two pointers start at opposite ends - left at the front, right at the back - and move towards each other, stopping when they meet. Each step either advances one pointer past an element to skip, or acts on the pair (compare, swap) and moves both inward.
Classic
125. Valid Palindrome
Reverse a Subarray
344. Reverse String
541. Reverse String II
2000. Reverse Prefix of Word
151. Reverse Words in a String
Medium·
Solutions:
FIG. 151 REVERSE WORDS IN A STRING● INTERACTIVE
186. Reverse Words in a String II
Medium·
Solutions:
FIG. 186 REVERSE WORDS IN A STRING II● INTERACTIVE
557. Reverse Words in a String III
Easy·
Solutions:
FIG. 557 REVERSE WORDS IN A STRING III● INTERACTIVE
Reverse Individual Elements
345. Reverse Vowels of a String
Easy·
Solutions:
FIG. 345 REVERSE VOWELS OF A STRING● INTERACTIVE
917. Reverse Only Letters
Rotate - Using Reverse
189. Rotate Array
Quick Left Rotation
Sorted Array
167. Two Sum II - Input Array Is Sorted
Medium·
Solutions:
FIG. 167 TWO SUM II INPUT ARRAY IS SORTED● INTERACTIVE
Sort the Array
977. Squares of a Sorted Array
Easy·
Solutions:
FIG. 977 SQUARES OF A SORTED ARRAY● INTERACTIVE