Two Sum II - Input Array Is Sorted
Learn how to solve Two Sum II (Input Array Is Sorted) using the two pointer technique in O(n) time and O(1) space, with a clear walkthrough and Python...
Sorted-array pair problems, fast/slow pointers, partitioning, merge-style and opposite-direction two-pointer techniques.
30 notes
Learn how to solve Two Sum II (Input Array Is Sorted) using the two pointer technique in O(n) time and O(1) space, with a clear walkthrough and Python...
Check if a string is a valid palindrome using two pointers, ignoring case and non-alphanumeric characters, in O(n) time and O(1) space.
Reverse only the vowels of a string in place using two pointers, in O(n) time.
Remove all occurrences of a value from an array in place using the slow/fast two pointer pattern, returning the new length in O(n).
Move all zeroes to the end of an array while keeping the order of non-zero elements, using two pointers in O(n) time and O(1) space.
Find the sum of three integers closest to a target using sorting plus the two pointer technique, in O(n^2) time.
Find all unique quadruplets that sum to a target using sorting, nested loops, and two pointers, in O(n^3) time.
Rearrange an array so even numbers come before odd numbers using two pointers, in place in O(n) time.
Return the squares of a sorted array in sorted order using two pointers from both ends, in O(n) time.
Merge two sorted arrays in place using two pointers from the back, in O(m+n) time and O(1) space.
Find the intersection of two arrays including duplicates using sorting and two pointers, in O(n log n) time.
Compare two strings containing backspace characters using two pointers scanning from the end, in O(n) time and O(1) space.