Message on Whatsapp 8879355057 for DSA(OA + Interview) + Fullstack Dev Training + 1-1 Personalized Mentoring to get 10+LPA Job
0 like 0 dislike
2,241 views
in Coding Resources by Expert (107,890 points) | 2,241 views

2 Answers

0 like 0 dislike
Best answer

Hello,
I have been solving all two pointers tagged problems in last 3.5 months, and wanted to share my findings/classifications here. If you are preparing for technical interview, two pointers is one of the popular topics that you can't skip :).

 

There are around 140 problems today on LC , but I only solved the public ones (117 problems).
Majority of them is in easy or medium so, if you understand the basic ideas then it should be solvable without much hints and editorials.

 

I see 4 bigger categories and many sub categories in it, and marked the typical example problems with (*).
I would recommend you to start solving these example problems, and apply the knowledge to the other problems. I don't want to copy & paste my ugly codes here, you would easily find fantastic solutions from the problem discussion page.

 

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

 

 

 

 

by Expert (107,890 points)
0 like 0 dislike
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

 

by Expert (107,890 points)