Post

LeetCode all two pointers problems

| 1. 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.
image

| 2.Slow & Fast Pointers | | — |

Next type is using two pointers with different speed of movement. Typically they starts from the left end, then the first pointer advances fast and give some feedback to the slow pointer and do some calculation.
image

| 3.Running from beginning of 2 arrays / Merging 2 arrays | | — |

In this category, you will be given 2 arrays or lists, then have to process them with individual pointers.
image

| 4.Split & Merge of an array / Divide & Conquer | | — |

The last one is similiar to previous category but there is one thing is added. First, you need to split the given list into 2 separate lists and then do two pointers approach to merge or unify them. There aren’t many tasks here.
image

This post is licensed under CC BY 4.0 by the author.

Comments powered by Disqus.