| Problem Names | Solution Writeups | Code |
|---|---|---|
| Valid Palindrome |
Create left and right pointer, check if both characters are same. Need to keep checking left < right when moving both pointers. |
|
| Two Sum II |
Since the array is sorted, create left and right pointers and do binary search method to determine the indices. |
|
| Three Sum |
Sort the array, for each number, first ensure it is not same as its previous number, and then find the two sum using left and right pointer. Need to prevent left pointer points to the same number when a solution is found. |
|
| Container With Most Water |
Use left and right pointer, record largest possible area, update left if min_height is left, update right if min_height is right. |
|
| Trapping Rain Water |
Create two pointers left and right that first point at index 0 and last index. Then when going through each position, to determine how many water it can trap, it only depends on the height of one side (either left/right). The formula is either left_max - height[left] or right_max - height[right]. To determine when to move which pointer (left/right), check if left_max < right_max, if yes update left, else updates right. left_max and right_max should keep track of highest height. |