Two pointers - broyda/cp-lib GitHub Wiki

  1. Most two pointer problems can be solved using binary search too, but the time complexity differs.
  2. If you have only one binary search, that can be convereted into a two pointer soluton. If there are more than 1 binary search, that cannot be converted to a binary search problem.
  3. Hint:
    If the order of the elements does NOT matter in a problem, sort the array since the algorithm may be simplified as a result of the sorting.