Array
Array manipulation techniques — rotating, searching, and rearranging elements efficiently
Basics
11Foundational 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.
Contains Duplicate
Check whether any value appears at least twice in the array.
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.
Summary Ranges
Compress consecutive integers into minimal summary ranges.
Contains Duplicate III
Check if two nearby values differ by at most valueDiff.
Missing Number
Find the missing value from the range 0 to n.
Missing Ranges
Find all ranges missing between lower and upper.
Set Mismatch
Find the duplicated and missing numbers in 1..n.
Two Pointers
7Pointer 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.
Remove Element
Remove all occurrences of a value in-place.
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
6Contiguous ranges, windows, streaks, and running best answers.
Zero-Filled Subarrays
Count how many subarrays consist entirely of zeros.
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
6Use 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.
Majority Element II
Find all numbers appearing more than n / 3 times.
Maximum Swap
Make the largest possible number by swapping two digits once.
Advanced Patterns
4Sorting-assisted, set-based, and multi-pass array techniques.
Increasing Triplet
Determine whether the array contains an increasing subsequence of length three.
3Sum
Find all unique triplets in the array whose sum is equal to zero.
Shortest Unsorted Continuous Subarray
Find the shortest subarray that must be sorted.
Mo's Algorithm
Answer offline range queries on an array by sorting queries into blocks and maintaining a moving [L, R] window.