Pattern
Two Pointers
A compact view of archive entries grouped by recurring technique.
61 entries
61 entries tagged as Two Pointers.
04.10.2025
medium11. Container With Most Water
Max water container from two heights
24.08.2025
medium1493. Longest Subarray of 1's After Deleting One Element
Max 1-subarray after removing one elemnt pointers
29.07.2025
medium2411. Smallest Subarrays With Maximum Bitwise OR
Shortest max OR i.. subarrays pointers
30.06.2025
easy594. Longest Harmonious Subsequence
Longest subsequence with max-min=1 pointers
29.06.2025
medium1498. Number of Subsequences That Satisfy the Given Sum Condition
Subsequencies target in 0..min+max search pointers
17.05.2025
medium75. Sort Colors
Sort 0,1,2 array pointers
29.04.2025
medium2962. Count Subarrays Where Max Element Appears at Least K Times
Subarrays at least k maxes pointers
28.04.2025
hard2302. Count Subarrays With Score Less Than K
Subarrays sum cnt <= k pointers
26.04.2025
hard2444. Count Subarrays With Fixed Bounds
Subarrays with min=minK, max=maxK pointers
24.04.2025
medium2799. Count Complete Subarrays in an Array
Subarrays having all uniqs pointers
19.04.2025
medium2563. Count the Number of Fair Pairs
Pairs a + b in lower..upper pointers
18.03.2025
medium2401. Longest Nice Subarray
Max window of all pairs AND zero pointers manipulation
11.03.2025
medium1358. Number of Substrings Containing All Three Characters
Substrings with [abc] pointers
10.03.2025
medium3306. Count of Substrings Containing Every Vowel and K Consonants II
Substring with all vowels and k others pointers
09.03.2025
medium3208. Alternating Groups II
Count cycling alterating k-subarrays pointers
03.03.2025
medium2161. Partition Array According to Given Pivot
Partition around p
02.03.2025
easy2570. Merge Two 2D Arrays by Summing Values
Merge two ascending [key, value] lists
14.12.2024
medium2762. Continuous Subarrays
Count subarrays with difference <= 2 queue set
09.12.2024
medium3152. Special Array II
Queries is all adjucents parity differ [i..j] pointers
06.12.2024
medium2554. Maximum Number of Integers to Choose From a Range I
Sum 1..n excluding banned until maxSum
20.11.2024
medium2516. Take K of Each Character From Left and Right
Min take k of a,b,c from head or tail pointers
19.11.2024
medium2461. Maximum Sum of Distinct Subarrays With Length K
Max k-unique window sum window
15.11.2024
medium1574. Shortest Subarray to be Removed to Make Array Sorted
Min subarray remove to make array sorted pointers
13.11.2024
medium2563. Count the Number of Fair Pairs
Count pairs a[i] + a[j] in lower..upper search pointers
04.11.2024
medium3163. String Compression III
Compress repeating chars in string pointers
01.11.2024
easy1957. Delete Characters to Make Fancy String
Filter 3+ repeating chars from string
08.10.2024
medium1963. Minimum Number of Swaps to Make the String Balanced
Min swaps to balance brackets pointers
05.10.2024
medium567. Permutation in String
Is s2 contains permutation of s1? pointers
04.10.2024
medium2491. Divide Players Into Teams of Equal Skill
Sum of products of pairs with equal sums
28.09.2024
medium641. Design Circular Deque
Ring buffer
15.09.2024
medium1371. Find the Longest Substring Containing Vowels in Even Counts
Longest substring with even number of "aeiou" manipulation pointers
14.09.2024
medium2419. Longest Subarray With Maximum Bitwise AND
Max bitwise AND subarray manipulation pointers
14.08.2024
hard719. Find K-th Smallest Pair Distance
kth smallest pairs diff in an array search pointers
04.08.2024
medium1508. Range Sum of Sorted Subarray Sums
Sum of [left..right] of sorted subarray's sums
2.07.2024
easy350. Intersection of Two Arrays II
Array intersection with duplicates
08.06.2024
medium523. Continuous Subarray Sum
Any subarray sum % k = 0
02.06.2024
easy344. Reverse String
Reverse an array
04.05.2024
medium881. Boats to Save People
Minimum total boats with at most 2 people & limit weight pointers
03.05.2024
medium165. Compare Version Numbers
Compare version numbers
02.05.2024
easy2441. Largest Positive Integer That Exists With Its Negative
Max number that has its negative in array pointers
30.04.2024
medium1915. Number of Wonderful Substrings
Count substrings with at most one odd frequency manipulation
27.03.2024
medium713. Subarray Product Less Than K
Subarrays count with product less than k
21.03.2024
easy206. Reverse Linked List
Reverse a Linked List
09.03.2024
easy2540. Minimum Common Value
First common number in two sorted arrays
06.03.2024
easy141. Linked List Cycle
Detect cycle
02.03.2024
easy977. Squares of a Sorted Array
Sorted squares.
14.02.2024
medium2149. Rearrange Array Elements by Sign
Rearrange array to positive-negative sequence.
1.01.2024
easy455. Assign Cookies
Max count of greedy children g[Int] to assign cookies with sizes s[Int].
1.10.2023
easy557. Reverse Words in a String III
Reverse words
23.09.2023
medium1048. Longest String Chain
Longest chain of words with single character added
22.09.2023
easy392. Is Subsequence
Is string a subsequence of another
25.08.2023
medium97. Interleaving String
Can a string be a merge of two other strings
6.07.2023
medium209. Minimum Size Subarray Sum
Min length subarray with sum >= target
5.07.2023
medium1493. Longest Subarray of 1's After Deleting One Element
Largest 1..1 subarray after removing one item
27.06.2023
medium373. Find K Pairs with Smallest Sums
List of increasing sum pairs a[i], b[j] from two sorted lists a, b
26.06.2023
medium2462. Total Cost to Hire K Workers
The sum of the smallest cost from suffix and prefix of a costs size of candidates in k iterations
05.04.2023
medium2439. Minimize Maximum of Array
careful with integers overflows
03.04.2023
medium881. Boats to Save People
Sort an array and move two pointers lo and hi.
09.03.2023
medium142. Linked List Cycle II
careful with corner cases.
6.02.2023
easy1470. Shuffle the Array
For simplicity, use two pointers for the source, and one for the destination.
4.11.2022
easyReverse Vowels Of A String
Straightforward solution : use two pointers method and scan from the both sides.