Two Pointers

Walk two indices through the data, usually from both ends or at different speeds, and decide which one to move at each step. It fits sorted arrays, pairs that meet a target, and in-place edits, as in 3Sum. It replaces a nested loop with one pass.

53 problems · 30 with a video · 6 to practice in an AI round

Two Pointers problems
#ProblemDifficultyVideoAI round
1Trapping Rain WaterHardAI round
23SumMediumAI round
3Container With Most WaterMediumAI round
4Longest Palindromic SubstringMediumAI round
5Find the Duplicate NumberMediumAI round
6Sort ColorsMediumAI round
7Next PermutationMedium—
8Remove Nth Node From End of ListMedium
9Rotate ArrayMedium—
10Move ZeroesEasy
11Merge Sorted ArrayEasy—
12Palindrome Linked ListEasy
13Linked List CycleEasy
14Intersection of Two Linked ListsEasy
15Linked List Cycle IIMedium
16Two Sum II - Input Array Is SortedMedium
17Middle of the Linked ListVery easy
18Sort ListMedium—
194SumMedium—
20Reorder ListMedium
21Happy NumberEasy
22Valid PalindromeEasy
233Sum ClosestMedium
24Palindromic SubstringsMedium
25Rotate ListMedium—
26Partition LabelsMedium
27Is SubsequenceEasy
28Reverse Words in a StringMedium—
29Squares of a Sorted ArrayVery easy
30Reverse StringVery easy—
31Remove Duplicates from Sorted List IIMedium
32Valid Palindrome IIEasy
33Remove Duplicates from Sorted Array IIMedium—
34Backspace String CompareEasy
35Longest String ChainMedium—
36Two Sum IV - Input is a BSTEasy—
37Intersection of Two ArraysEasy—
38Boats to Save PeopleMedium
39Reverse Words in a String IIIVery easy
40Sort Array By ParityVery easy—
41Assign CookiesEasy—
42Delete the Middle Node of a Linked ListMedium—
43Merge Strings AlternatelyVery easy—
44Count Binary SubstringsEasy—
45Partition Array Into Two Arrays to Minimize Sum DifferenceHard—
46Sum of Square NumbersMedium
47Find the CelebrityMedium—
48Reverse Only LettersEasy
49Reverse Prefix of WordVery easy
50Lowest Common Ancestor of a Binary Tree IIIMedium—
51One Edit DistanceMedium—
52Sort Transformed ArrayMedium—
53Last Substring in Lexicographical OrderVery hard—

Practice in an AI round

Six of these are AI rounds: 30 minutes, an AI agent beside your code, then a scored report.

Practice Trapping Rain Water in an AI round