Algorithms: Two Pointers

Piyush Bag
Dec 2, 2020

Approach to Two Pointer problems

Strings Comparison containing Backspaces

3 parts of this Algorithm:

  1. Iterate the function to find the next valid character index.
  2. 3 conditions to cover for True and False.
  3. Update the index and repeat steps 1 and 2.

Sorted Minimum Window

3 Parts of this Algorithm:

  1. Find the first unsorted element from the left parallelly, find the first unsorted element from the right.

1.1 Edge Case

2. Find the minimum and maximum element.

3. Recheck the minimum and maximum element is at its first and last element or not.

Return the difference between the maximum and minimum pointer.

--

--

Piyush Bag

A Software Developer trying to disrupt one industry (at least)