# Running from both ends of an array

The first type of problems are, having two pointers at left and right end of array, then moving them to the center while processing something with them.

<figure><img src="https://1388126071-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MVQ7Ie-PZpN_8yApX0-%2Fuploads%2FCoXEHgjDBszUfQe84Ejj%2Fimage.png?alt=media&#x26;token=7e76eb1f-6b69-4d2b-b748-551c4e529532" alt=""><figcaption></figcaption></figure>

* 2 Sum problem\
  (\*) <https://leetcode.com/problems/two-sum-ii-input-array-is-sorted/>\
  <https://leetcode.com/problems/3sum/>\
  <https://leetcode.com/problems/4sum/>\
  <https://leetcode.com/problems/number-of-subsequences-that-satisfy-the-given-sum-condition/>\
  <https://leetcode.com/problems/two-sum-iv-input-is-a-bst/>\
  <https://leetcode.com/problems/sum-of-square-numbers/>\
  <https://leetcode.com/problems/boats-to-save-people/>\
  <https://leetcode.com/problems/minimize-maximum-pair-sum-in-array/>\
  <https://leetcode.com/problems/3sum-with-multiplicity/>
* Trapping Water\
  (\*) <https://leetcode.com/problems/trapping-rain-water/>\
  <https://leetcode.com/problems/container-with-most-water/>
* Next Permutation\
  (\*) <https://leetcode.com/problems/next-permutation/>\
  <https://leetcode.com/problems/next-greater-element-iii/>\
  <https://leetcode.com/problems/minimum-adjacent-swaps-to-reach-the-kth-smallest-number/>
* Reversing / Swapping\
  <https://leetcode.com/problems/valid-palindrome/>\
  (\*) <https://leetcode.com/problems/reverse-string/>\
  <https://leetcode.com/problems/reverse-vowels-of-a-string/>\
  <https://leetcode.com/problems/valid-palindrome-ii/>\
  <https://leetcode.com/problems/reverse-only-letters/>\
  <https://leetcode.com/problems/remove-element/>\
  <https://leetcode.com/problems/sort-colors/>\
  <https://leetcode.com/problems/flipping-an-image/>\
  <https://leetcode.com/problems/squares-of-a-sorted-array/>\
  <https://leetcode.com/problems/sort-array-by-parity/>\
  <https://leetcode.com/problems/sort-array-by-parity-ii/>\
  <https://leetcode.com/problems/pancake-sorting/>\
  <https://leetcode.com/problems/reverse-prefix-of-word/>\
  <https://leetcode.com/problems/reverse-string-ii/>\
  <https://leetcode.com/problems/reverse-words-in-a-string/>\
  <https://leetcode.com/problems/reverse-words-in-a-string-iii/>
* Others\
  <https://leetcode.com/problems/bag-of-tokens/>\
  <https://leetcode.com/problems/di-string-match/>\
  <https://leetcode.com/problems/minimum-length-of-string-after-deleting-similar-ends/>\
  <https://leetcode.com/problems/sentence-similarity-iii/>\
  <https://leetcode.com/problems/find-k-closest-elements/>\
  <https://leetcode.com/problems/shortest-distance-to-a-character/>
