Skip to content

Two Pointers Problems

182 Two Pointers LeetCode problems · Browse tasks by difficulty and choose your next practice problem.

Learn the coding interview patterns behind these problems.

Start with these

All Two Pointers problems

5 Longest Palindromic Substring Medium11 Container With Most Water Medium15 3Sum Medium16 3Sum Closest Medium18 4Sum Medium19 Remove Nth Node From End of List Medium26 Remove Duplicates from Sorted Array Easy27 Remove Element Easy28 Find the Index of the First Occurrence in a String Easy31 Next Permutation Medium42 Trapping Rain Water Hard61 Rotate List Medium75 Sort Colors Medium80 Remove Duplicates from Sorted Array II Medium82 Remove Duplicates from Sorted List II Medium86 Partition List Medium88 Merge Sorted Array Easy125 Valid Palindrome Easy141 Linked List Cycle Easy142 Linked List Cycle II Medium143 Reorder List Medium148 Sort List Medium151 Reverse Words in a String Medium160 Intersection of Two Linked Lists Easy165 Compare Version Numbers Medium167 Two Sum II - Input Array Is Sorted Medium189 Rotate Array Medium202 Happy Number Easy234 Palindrome Linked List Easy283 Move Zeroes Easy287 Find the Duplicate Number Medium295 Find Median from Data Stream Hard321 Create Maximum Number Hard344 Reverse String Easy345 Reverse Vowels of a String Easy349 Intersection of Two Arrays Easy350 Intersection of Two Arrays II Easy392 Is Subsequence Easy443 String Compression Medium455 Assign Cookies Easy457 Circular Array Loop Medium475 Heaters Medium481 Magical String Medium522 Longest Uncommon Subsequence II Medium524 Longest Word in Dictionary through Deleting Medium532 K-diff Pairs in an Array Medium541 Reverse String II Easy556 Next Greater Element III Medium557 Reverse Words in a String III Easy567 Permutation in String Medium581 Shortest Unsorted Continuous Subarray Medium611 Valid Triangle Number Medium633 Sum of Square Numbers Medium647 Palindromic Substrings Medium653 Two Sum IV - Input is a BST Easy658 Find K Closest Elements Medium680 Valid Palindrome II Easy696 Count Binary Substrings Easy719 Find K-th Smallest Pair Distance Hard763 Partition Labels Medium777 Swap Adjacent in LR String Medium786 K-th Smallest Prime Fraction Medium795 Number of Subarrays with Bounded Maximum Medium809 Expressive Words Medium821 Shortest Distance to a Character Easy825 Friends Of Appropriate Ages Medium826 Most Profit Assigning Work Medium832 Flipping an Image Easy838 Push Dominoes Medium844 Backspace String Compare Easy845 Longest Mountain in Array Medium870 Advantage Shuffle Medium876 Middle of the Linked List Easy881 Boats to Save People Medium905 Sort Array By Parity Easy917 Reverse Only Letters Easy922 Sort Array By Parity II Easy923 3Sum With Multiplicity Medium925 Long Pressed Name Easy942 DI String Match Easy948 Bag of Tokens Medium962 Maximum Width Ramp Medium969 Pancake Sorting Medium977 Squares of a Sorted Array Easy986 Interval List Intersections Medium1023 Camelcase Matching Medium1048 Longest String Chain Medium1089 Duplicate Zeros Easy1147 Longest Chunked Palindrome Decomposition Hard1163 Last Substring in Lexicographical Order Hard1237 Find Positive Integer Solution for a Given Equation Medium1332 Remove Palindromic Subsequences Easy1346 Check If N and Its Double Exist Easy1385 Find the Distance Value Between Two Arrays Easy1455 Check If a Word Occurs As a Prefix of Any Word in a Sentence Easy1471 The k Strongest Values in an Array Medium1498 Number of Subsequences That Satisfy the Given Sum Condition Medium1508 Range Sum of Sorted Subarray Sums Medium1537 Get the Maximum Score Hard1574 Shortest Subarray to be Removed to Make Array Sorted Medium1577 Number of Ways Where Square of Number Is Equal to Product of Two Numbers Medium1616 Split Two Strings to Make Palindrome Medium1679 Max Number of K-Sum Pairs Medium1697 Checking Existence of Edge Length Limited Paths Hard1712 Ways to Split Array Into Three Subarrays Medium1721 Swapping Nodes in a Linked List Medium1750 Minimum Length of String After Deleting Similar Ends Medium1754 Largest Merge Of Two Strings Medium1755 Closest Subsequence Sum Hard1764 Form Array by Concatenating Subarrays of Another Array Medium1768 Merge Strings Alternately Easy1782 Count Pairs Of Nodes Hard1793 Maximum Score of a Good Subarray Hard1813 Sentence Similarity III Medium1850 Minimum Adjacent Swaps to Reach the Kth Smallest Number Medium1855 Maximum Distance Between a Pair of Values Medium1861 Rotating the Box Medium1877 Minimize Maximum Pair Sum in Array Medium1898 Maximum Number of Removable Characters Medium1961 Check If String Is a Prefix of Array Easy1963 Minimum Number of Swaps to Make the String Balanced Medium2000 Reverse Prefix of Word Easy2035 Partition Array Into Two Arrays to Minimize Sum Difference Hard2071 Maximum Number of Tasks You Can Assign Hard2095 Delete the Middle Node of a Linked List Medium2105 Watering Plants II Medium2108 Find First Palindromic String in the Array Easy2109 Adding Spaces to a String Medium2122 Recover the Original Array Hard2130 Maximum Twin Sum of a Linked List Medium2149 Rearrange Array Elements by Sign Medium2161 Partition Array According to Given Pivot Medium2193 Minimum Number of Moves to Make Palindrome Hard2200 Find All K-Distant Indices in an Array Easy2234 Maximum Total Beauty of the Gardens Hard2300 Successful Pairs of Spells and Potions Medium2332 The Latest Time to Catch a Bus Medium2337 Move Pieces to Obtain a String Medium2367 Number of Arithmetic Triplets Easy2396 Strictly Palindromic Number Medium2406 Divide Intervals Into Minimum Number of Groups Medium2410 Maximum Matching of Players With Trainers Medium2441 Largest Positive Integer That Exists With Its Negative Easy2460 Apply Operations to an Array Easy2462 Total Cost to Hire K Workers Medium2465 Number of Distinct Averages Easy2472 Maximum Number of Non-overlapping Palindrome Substrings Hard2486 Append Characters to String to Make Subsequence Medium2491 Divide Players Into Teams of Equal Skill Medium2503 Maximum Number of Points From Grid Queries Hard2511 Maximum Enemy Forts That Can Be Captured Easy2540 Minimum Common Value Easy2562 Find the Array Concatenation Value Easy2563 Count the Number of Fair Pairs Medium2565 Subsequence With the Minimum Score Hard2570 Merge Two 2D Arrays by Summing Values Easy2576 Find the Maximum Number of Marked Indices Medium2592 Maximize Greatness of an Array Medium2697 Lexicographically Smallest Palindrome Easy2824 Count Pairs Whose Sum is Less than Target Easy2825 Make String a Subsequence Using Cyclic Increments Medium2856 Minimum Array Length After Pair Removals Medium2903 Find Indices With Index and Value Difference I Easy2905 Find Indices With Index and Value Difference II Medium2911 Minimum Changes to Make K Semi-palindromes Hard2938 Separate Black and White Balls Medium2970 Count the Number of Incremovable Subarrays I Easy2972 Count the Number of Incremovable Subarrays II Hard3006 Find Beautiful Indices in the Given Array I Medium3008 Find Beautiful Indices in the Given Array II Hard3132 Find the Integer Added to Array II Medium3186 Maximum Total Damage With Spell Casting Medium3194 Minimum Average of Smallest and Largest Elements Easy3239 Minimum Number of Flips to Make Binary Grid Palindromic I Medium3240 Minimum Number of Flips to Make Binary Grid Palindromic II Medium3302 Find the Lexicographically Smallest Valid Sequence Medium3316 Find Maximum Removals From Source String Medium3403 Find the Lexicographically Largest String From the Box I Medium3455 Shortest Matching Substring Hard3503 Longest Palindrome After Substring Concatenation I Medium3504 Longest Palindrome After Substring Concatenation II Hard3584 Maximum Product of First and Last Elements of a Subsequence Medium