Two Pointers coding problems
Two-pointer problems walk an array from both ends or at two speeds to cut an O(n²) idea down to O(n): pair sums, removing duplicates, merging sorted lists and partitioning.
35 problems: 10 easy, 21 medium, 4 hard. Free to read; a free account solves them and earns XP and Aura.
- Count Pairs with Smaller SumPractice · +10 XP · two pointers, sorting, countingeasy
- Count Pairs with Specific SumPractice · +10 XP · sliding window, two pointers, arrayseasy
- Find Duplicate in Sorted ArrayPractice · +10 XP · two pointers, arrays, binary searcheasy
- Find First Element Greater Than KPractice · +10 XP · two pointers, binary search, sorted arrayeasy
- Find First Even NumberPractice · +10 XP · two pointers, arrays, searchingeasy
- Find Pair with SumPractice · +10 XP · two pointers, array, two sumeasy
- Find Smallest Missing Positive IntegerPractice · +10 XP · two pointers, binary search, arrayseasy
- Reverse Array ElementsPractice · +10 XP · two pointers, array manipulation, beginnereasy
- Sum of Adjacent ElementsPractice · +10 XP · two pointers, arrays, loopseasy
- Two Pointers SumPractice · +10 XP · two pointers, arrays, two sumeasy
- Array of SubarraysDaily · +15 XP · +5 Aura (late, half) · hash map, two pointers, subarray2 solvedmedium
- Count Subarrays with Distinct ElementsPractice · +20 XP · hash map, sliding window, two pointersmedium
- Count Unique Element PairsPractice · +20 XP · hash map, two pointers, sortingmedium
- Cycle Detection and RendezvousPractice · +20 XP · linked structures, cycle detection, two pointersmedium
- Find First Duplicate Entry PointPractice · +20 XP · linked structures, cycle detection, two pointersmedium
- K-th Node in CyclePractice · +20 XP · linked structures, cycles, two pointersmedium
- Longest Sorted SubsegmentPractice · +20 XP · two pointers, arrays, sliding windowmedium
- Longest Subarray with Alternating ParityPractice · +20 XP · sliding window, two pointers, paritymedium
- Longest Subarray with At Most K Distinct ElementsPractice · +20 XP · two pointers, sliding window, hash mapmedium
- Longest Subarray with Bounded DifferencePractice · +20 XP · two pointers, sliding window, data structuresmedium
- Longest Subarray with Constant DifferencePractice · +20 XP · two pointers, greedy, arraysmedium
- Longest Subarray with Increasing SumPractice · +20 XP · two pointers, subarray, sliding windowmedium
- Longest Subarray with Limited DifferencePractice · +20 XP · two pointers, sliding window, greedymedium
- Longest Subarray with Sum at Most KPractice · +20 XP · sliding window, prefix sums, two pointersmedium
- Longest Symmetric SubstringPractice · +20 XP · strings, dynamic programming, two pointersmedium
- Max Consecutive SumPractice · +20 XP · two pointers, dynamic programming, greedymedium
- Minimize Maximum Difference in PairsPractice · +20 XP · greedy, sorting, two pointersmedium
- Optimal Apartment RentalPractice · +20 XP · binary search, two pointersmedium
- Optimal Training ScheduleOpen now · Weekly · +40 XP · +15 Aura · two pointers, sliding window, prefix sum1 solvedmedium
- Pairs with Same ParityPractice · +20 XP · sorting, two pointers, combinatoricsmedium
- String BalancePractice · +20 XP · strings, two pointersmedium
- Distinct Subarrays with Bounded SumPractice · +30 XP · two pointers, hash map, combinatoricshard
- Longest Subarray with Distinct ElementsPractice · +30 XP · hash map, sliding window, two pointershard
- Longest Subarray with Equal Number of Zeroes and OnesPractice · +30 XP · two pointers, prefix sum, hash maphard
- Minimum Window SubstringPractice · +30 XP · sliding window, two pointers, stringshard
Solve these free. Get paid in XP and Aura.
One tap with Google, no card. Every first accepted solve pays XP for the leaderboards and Aura for real goodies.
Other topics
Hash Map and Hashing101Arrays88Prefix Sums64SQL and Databases64Beginner Coding Problems60Graphs, BFS and DFS45Greedy41Sliding Window39Dynamic Programming37Sorting36Math and Number Theory36Strings35Stack29Binary Search25Simulation25Recursion22Linked List20Trees20Heap and Priority Queue18Matrix and Grid18Bit Manipulation18Queue and Deque16