Two pointers

Two pointers

The two pointers technique is a generalization of the Sliding-window technique. The primary difference is that the two pointers can cross over one another and could reference different arrays.

Common use cases

  • Palindromic sub-strings
  • Sorting colors
  • Merging sorted arrays