Array
Array manipulation techniques — rotating, searching, and rearranging elements efficiently
Basics
5Foundational array transformations and simple scans.
Concatenation of Array
Build a new array by appending nums to itself.
Shuffle the Array
Rearrange the array by interleaving elements from two halves using a given n.
Running Sum of 1D Array
Build a running sum array where each position stores the sum up to that index.
Single Number
Find the element that appears exactly once when every other element appears twice.
Third Maximum Number
Find the third distinct maximum number in one traversal.
Two Pointers
6Pointer movement, swaps, and in-place rearrangement patterns.
Rotate Array
Rotate an array to the right by k steps using the efficient reversal algorithm.
Move Zeros
Move all zeros to the end while preserving the relative order of non-zero elements.
Remove Duplicates from Sorted Array
Remove duplicates from a sorted array in-place so each unique element appears once.
Two Sum II - Input Array Is Sorted
Find two numbers in the sorted array whose sum equals the target using the Two Pointer technique.
Sort Colors
Sort an array containing only 0s, 1s, and 2s in-place.
Squares of a Sorted Array
Compare squares from both ends and fill the result array from right to left using two pointers.
Searching & Indexing
5Find targets, missing values, pivots, and index-based answers.
Two Sum
Find two indices in the array such that their values add up to a given target using an efficient hash map approach.
First Missing Positive
Find the smallest missing positive number using cyclic index placement.
Find Closest Number to Zero
Find the number in the array that is closest to zero.
Find Pivot Index
Find an index where the sum on the left equals the sum on the right.
Find All Numbers Disappeared in an Array
Find all missing numbers from the range [1, n] using Cyclic Sort.
Subarray & Sliding Window
5Contiguous ranges, windows, streaks, and running best answers.
Maximum Subarray
Find the contiguous subarray with the largest sum using Kadane’s Algorithm.
Max Consecutive Ones III
Find the longest subarray with at most k zeros (flip zeros to ones)
Maximum Product Subarray
Find the contiguous subarray that has the largest product.
Minimum Size Subarray Sum
Find the smallest length of a contiguous subarray whose sum is at least the target.
Max Consecutive Ones
Find the maximum number of consecutive 1s in a binary array.
Prefix, Product & Accumulators
4Use accumulated state to avoid repeated work.
Best Time to Buy and Sell Stock
Find the maximum profit by choosing one day to buy and a later day to sell.
Buy and Sell Stock II
Find the maximum profit by making multiple buy and sell transactions.
Product of Array
Return an array where each element is the product of all other elements except itself.
Majority Element
Find the element that appears more than n / 2 times.
Advanced Patterns
2Sorting-assisted, set-based, and multi-pass array techniques.