Two Pointers
49 problems · 39 with full explanations
13 Easy29 Medium1 Hard
The two-pointer technique places pointers at different positions (often the two ends) and moves them toward each other. It turns O(n²) nested loops into O(n) sweeps for problems like pair sums, removing duplicates, and container capacity. Works best on sorted or partitioned arrays.
How to practice
To practice Two Pointers problems effectively, start with the Easy problems listed below, trace through each solution on paper, then re-implement without looking. When you can recognise the two pointers pattern within 30 seconds of reading a new problem, move on to Medium difficulty. Use the related topic pages and our study guide for a structured progression.
Start here (Easy + explained)
All Two Pointers problems
- 11.Container With Most WaterMedium
- 15.3SumMedium
- 16.3Sum ClosestMedium
- 19.Remove Nth Node From End of ListMedium
- 26.Remove Duplicates from Sorted ArrayEasy
- 27.Remove ElementEasy
- 61.Rotate ListMedium
- 75.Sort ColorsMedium
- 86.Partition ListMedium
- 160.Intersection of Two Linked ListsEasy
- 165.Compare Version NumbersMedium
- 189.Rotate ArrayMedium
- 202.Happy NumberEasy
- 321.Create Maximum NumberUnknown
- 324.Wiggle Sort IIMedium
- 344.Reverse StringEasy
- 350.Intersection of Two Arrays IIEasy
- 567.Permutation in StringMedium
- 611.Valid Triangle NumberMedium
- 633.Sum of Square NumbersMedium
- 658.Find K Closest ElementsMedium
- 696.Count Binary SubstringsEasy
- 719.Find K-th Smallest Pair DistanceHard
- 763.Partition LabelsMedium
- 825.Friends Of Appropriate AgesMedium
- 826.Most Profit Assigning WorkMedium
- 838.Push DominoesMedium
- 905.Sort Array By ParityEasy
- 917.Reverse Only LettersEasy
- 1346.Check If N and Its Double ExistUnknown
- 1498.Number of Subsequences That Satisfy the Given Sum ConditionMedium
- 1508.Range Sum of Sorted Subarray SumsMedium
- 1574.Shortest Subarray to be Removed to Make Array SortedUnknown
- 1768.Merge Strings AlternatelyEasy
- 1813.Sentence Similarity IIIUnknown
- 1861.Rotating the BoxEasy
- 1877.Minimize Maximum Pair Sum in ArrayEasy
- 1963.Minimum Number of Swaps to Make the String BalancedUnknown
- 2058.Find the Minimum and Maximum Number of Nodes Between Critical PointsUnknown
- 2161.Partition Array According to Given PivotMedium
- 2300.Successful Pairs of Spells and PotionsMedium
- 2337.Move Pieces to Obtain a StringMedium
- 2410.Maximum Matching of Players With TrainersMedium
- 2491.Divide Players Into Teams of Equal SkillMedium
- 2563.Count the Number of Fair PairsMedium
- 2570.Merge Two 2D Arrays by Summing ValuesMedium
- 2825.Make String a Subsequence Using Cyclic IncrementsMedium
- 2938.Separate Black and White BallsMedium
- 3474.Lexicographically Smallest Generated StringEasy