Arrays
Ordered indexable collection for O(1) access by position.
Arrays Practice Problems
Easy
20 problems- 274easy
Two Sum
Find the two numbers in an array that add up to a target value.
- 275easy
Remove Element
Remove every occurrence of a value from an array in place.
- 276easy
Plus One
Add one to a large number represented as an array of digits.
- 277easy
Pascal's Triangle
Build the first few rows of Pascal's triangle.
- 278easy
Majority Element
Find the value that appears in more than half the array.
- 279easy
Find All Numbers Disappeared in an Array
Find every number missing from a 1..n ranged array, in place.
- 280easy
Third Maximum Number
Find the third distinct largest number in an array.
- 281easy
Array Partition
Pair up array values to maximize the sum of each pair’s minimum.
- 282easy
Check If N and Its Double Exist
Check whether one array value is exactly double another.
- 283easy
Replace Elements with Greatest Element on Right Side
Replace each value with the greatest value to its right.
- 284easy
Duplicate Zeros
Duplicate every zero in place, shifting later values right.
- 285easy
Shuffle the Array
Interleave two halves of an array back into one sequence.
- 286easy
Build Array from Permutation
Build a new array where each value is looked up through itself.
- 287easy
Concatenation of Array
Concatenate an array with itself into one longer array.
- 288easy
Richest Customer Wealth
Find the customer with the most total money across accounts.
- 289easy
Kids With the Greatest Number of Candies
Check which kids could have the most candies after a bonus.
- 290easy
Monotonic Array
Check whether an array is entirely non-increasing or non-decreasing.
- 291easy
Find Numbers with Even Number of Digits
Count how many numbers in an array have an even digit count.
- 292easy
Maximum Product of Two Elements in an Array
Maximize (a-1) * (b-1) over two distinct array elements.
- 293easy
Transpose Matrix
Flip a matrix over its main diagonal.
Medium
14 problems- 294medium
Pivot Array
Partition an array around a pivot value while keeping relative order.
- 295medium
Spiral Matrix
Return every element of a matrix in spiral order.
- 296medium
Rotate Image
Rotate a square matrix 90 degrees in place.
- 297medium
Set Matrix Zeroes
Zero out the row and column of every zero in a matrix, in place.
- 298medium
Game of Life
Advance a grid of cells one generation under Conway’s rules, in place.
- 299medium
Next Greater Element II
Find the next greater value for each element in a circular array.
- 300medium
Daily Temperatures
Find how many days until a warmer temperature, for each day.
- 301medium
Majority Element II
Find every value that appears more than n/3 times in an array.
- 302medium
Find the Duplicate Number
Find the one repeated number without modifying the array.
- 303medium
Non-decreasing Array
Check if an array can become non-decreasing by changing one element.
- 304medium
Array Nesting
Find the longest cycle formed by repeatedly indexing into a permutation.
- 305medium
4Sum II
Count quadruples across four arrays whose sums add up to zero.
- 306medium
Wiggle Sort
Reorder an array in place so it alternately rises and falls.
- 307medium
Find All Duplicates in an Array
Find every value that appears twice in an array, in place.
Hard
9 problems- 309hard
First Missing Positive
Find the smallest missing positive integer in O(n) time and O(1) space.
- 310hard
Best Time to Buy and Sell Stock III
Maximize profit across at most two non-overlapping trades.
- 311hard
Best Time to Buy and Sell Stock IV
Maximize profit across at most k non-overlapping trades.
- 312hard
Longest Consecutive Sequence
Find the longest run of consecutive integers in an unsorted array.
- 313hard
Russian Doll Envelopes
Find the longest chain of envelopes that each nest inside the next.
- 314hard
Maximum Profit in Job Scheduling
Pick non-overlapping jobs that maximize total profit.
- 315hard
Minimum Number of Operations to Make Array Continuous
Find the fewest replacements needed to make an array a consecutive run.
- 317hard
Count Subarrays With Fixed Bounds
Count subarrays whose minimum and maximum match two fixed bounds.
- 318hard
Minimum Cost to Hire K Workers
Hire k workers at minimum total cost while respecting wage ratios.
Related concepts
| Topic | Description |
|---|---|
| Sliding Window | Solve fixed-window problems: maximum sum of k elements, moving averages, and O(n) updates as the window slides. |
| Two Pointers | Scan a sorted array or string from both ends at once to find pairs, remove duplicates, or reverse data in O(n). |
| Linked Lists | Nodes linked by pointers — insert and delete without shifting a contiguous block. |
| Stacks | Last-in, first-out collection for undo, parsing, and nested work. |
| Queues | First-in, first-out collection for scheduling, BFS, and buffering. |
| Hash Tables | Key-to-value lookup in average O(1) via hashing into buckets. |