Two Pointers | LeetCode Problems

167 Two Pointers solutions to LeetCode solutions.

Two Pointers Problems View all solutions →

Longest Palindromic Substring

#5 Medium

Container With Most Water

#11 Medium

3Sum

#15 Medium

3Sum Closest

#16 Medium

4Sum

#18 Medium

Remove Nth Node From End of List

#19 Medium

Remove Duplicates from Sorted Array

#26 Easy

Remove Element

#27 Easy

Implement strStr()

#28 Easy

Next Permutation

#31 Medium

Trapping Rain Water

#42 Hard

Rotate List

#61 Medium

Sort Colors

#75 Medium

Remove Duplicates from Sorted Array II

#80 Medium

Remove Duplicates from Sorted List II

#82 Medium

Partition List

#86 Medium

Merge Sorted Array

#88 Easy

Valid Palindrome

#125 Easy

Linked List Cycle

#141 Easy

Linked List Cycle II

#142 Medium

Reorder List

#143 Medium

Sort List

#148 Medium

Reverse Words in a String

#151 Medium

Intersection of Two Linked Lists

#160 Medium

One Edit Distance

#161 Medium

Compare Version Numbers

#165 Medium

Two Sum II - Input Array Is Sorted

#167 Easy

Two Sum III - Data structure design

#170 Easy

Reverse Words in a String II

#186 Medium

Rotate Array

#189 Medium

Happy Number

#202 Easy

Palindrome Linked List

#234 Easy

Shortest Word Distance II

#244 Medium

Strobogrammatic Number

#246 Easy

Move Zeroes

#283 Easy

Find the Duplicate Number

#287 Medium

Find Median from Data Stream

#295 Hard

Create Maximum Number

#321 Hard

Reverse String

#344 Easy

Reverse Vowels of a String

#345 Easy

Intersection of Two Arrays

#349 Easy

Intersection of Two Arrays II

#350 Easy

Is Subsequence

#392 Easy

String Compression

#443 Medium

Assign Cookies

#455 Easy

Circular Array Loop

#457 Medium

Heaters

#475 Medium

Magical String

#481 Medium

Longest Uncommon Subsequence II

#522 Medium

Longest Word in Dictionary through Deleting

#524 Medium

K-diff Pairs in an Array

#532 Medium

Reverse String II

#541 Easy

Next Greater Element III

#556 Medium

Reverse Words in a String III

#557 Easy

Permutation in String

#567 Medium

Shortest Unsorted Continuous Subarray

#581 Medium

Valid Triangle Number

#611 Medium

Sum of Square Numbers

#633 Medium

Palindromic Substrings

#647 Medium

Two Sum IV - Input is a BST

#653 Easy

Find K Closest Elements

#658 Medium

Valid Palindrome II

#680 Easy

Count Binary Substrings

#696 Easy

Find K-th Smallest Pair Distance

#719 Hard

Partition Labels

#763 Medium

Swap Adjacent in LR String

#777 Medium

K-th Smallest Prime Fraction

#786 Medium

Number of Subarrays with Bounded Maximum

#795 Medium

Expressive Words

#809 Medium

Shortest Distance to a Character

#821 Easy

Friends Of Appropriate Ages

#825 Medium

Most Profit Assigning Work

#826 Medium

Flipping an Image

#832 Easy

Push Dominoes

#838 Medium

Backspace String Compare

#844 Easy

Longest Mountain in Array

#845 Medium

Advantage Shuffle

#870 Medium

Middle of the Linked List

#876 Easy

Boats to Save People

#881 Medium

Sort Array By Parity

#905 Easy

Reverse Only Letters

#917 Easy

Sort Array By Parity II

#922 Easy

3Sum With Multiplicity

#923 Medium

Long Pressed Name

#925 Easy

DI String Match

#942 Easy

Bag of Tokens

#948 Medium

Maximum Width Ramp

#962 Medium

Pancake Sorting

#969 Medium

Squares of a Sorted Array

#977 Easy

Interval List Intersections

#986 Medium

Camelcase Matching

#1023 Medium

Moving Stones Until Consecutive II

#1040 Medium

Longest String Chain

#1048 Medium

Duplicate Zeros

#1089 Easy

Longest Chunked Palindrome Decomposition

#1147 Hard

Last Substring in Lexicographical Order

#1163 Hard

Find Positive Integer Solution for a Given Equation

#1237 Medium

Remove Palindromic Subsequences

#1332 Easy

Check If N and Its Double Exist

#1346 Easy

Find the Distance Value Between Two Arrays

#1385 Easy

Check If a Word Occurs As a Prefix of Any Word in a Sentence

#1455 Easy

The k Strongest Values in an Array

#1471 Medium

Number of Subsequences That Satisfy the Given Sum Condition

#1498 Medium

Range Sum of Sorted Subarray Sums

#1508 Medium

Get the Maximum Score

#1537 Hard

Shortest Subarray to be Removed to Make Array Sorted

#1574 Medium

Number of Ways Where Square of Number Is Equal to Product of Two Numbers

#1577 Medium

Split Two Strings to Make Palindrome

#1616 Medium

Max Number of K-Sum Pairs

#1679 Medium

Checking Existence of Edge Length Limited Paths

#1697 Hard

Ways to Split Array Into Three Subarrays

#1712 Medium

Swapping Nodes in a Linked List

#1721 Medium

Minimum Length of String After Deleting Similar Ends

#1750 Medium

Largest Merge Of Two Strings

#1754 Medium

Closest Subsequence Sum

#1755 Hard

Form Array by Concatenating Subarrays of Another Array

#1764 Medium

Merge Strings Alternately

#1768 Easy

Count Pairs Of Nodes

#1782 Hard

Maximum Score of a Good Subarray

#1793 Hard

Sentence Similarity III

#1813 Medium

Minimum Adjacent Swaps to Reach the Kth Smallest Number

#1850 Medium

Maximum Distance Between a Pair of Values

#1855 Medium

Rotating the Box

#1861 Medium

Minimize Maximum Pair Sum in Array

#1877 Medium

Maximum Number of Removable Characters

#1898 Medium

Check If String Is a Prefix of Array

#1961 Easy

Minimum Number of Swaps to Make the String Balanced

#1963 Medium

Reverse Prefix of Word

#2000 Easy

Partition Array Into Two Arrays to Minimize Sum Difference

#2035 Hard

Delete the Middle Node of a Linked List

#2095 Medium

Watering Plants II

#2105 Medium

Find First Palindromic String in the Array

#2108 Easy

Adding Spaces to a String

#2109 Medium

Recover the Original Array

#2122 Hard

Maximum Twin Sum of a Linked List

#2130 Medium

Rearrange Array Elements by Sign

#2149 Medium

Partition Array According to Given Pivot

#2161 Medium

Minimum Number of Moves to Make Palindrome

#2193 Hard

Find All K-Distant Indices in an Array

#2200 Easy

Maximum Total Beauty of the Gardens

#2234 Hard

Successful Pairs of Spells and Potions

#2300 Medium

Move Pieces to Obtain a String

#2337 Medium

Number of Arithmetic Triplets

#2367 Easy

Strictly Palindromic Number

#2396 Medium

Maximum Matching of Players With Trainers

#2410 Medium

Largest Positive Integer That Exists With Its Negative

#2441 Easy

Apply Operations to an Array

#2460 Easy

Total Cost to Hire K Workers

#2462 Medium

Number of Distinct Averages

#2465 Easy

Maximum Number of Non-overlapping Palindrome Substrings

#2472 Hard

Append Characters to String to Make Subsequence

#2486 Medium

Divide Players Into Teams of Equal Skill

#2491 Medium

Maximum Number of Points From Grid Queries

#2503 Hard

Maximum Enemy Forts That Can Be Captured

#2511 Easy

Minimum Common Value

#2540 Easy

Find the Array Concatenation Value

#2562 Easy

Count the Number of Fair Pairs

#2563 Medium

Merge Two 2D Arrays by Summing Values

#2570 Easy

Find the Maximum Number of Marked Indices

#2576 Medium

Maximize Greatness of an Array

#2592 Medium

Lexicographically Smallest Palindrome

#2697 Easy

Count Pairs Whose Sum is Less than Target

#2824 Easy

Make String a Subsequence Using Cyclic Increments

#2825 Medium

Find Indices With Index and Value Difference I

#2903 Easy

Separate Black and White Balls

#2938 Medium

Count the Number of Incremovable Subarrays I

#2970 Easy

Find the Lexicographically Largest String From the Box I

#3403 Medium