Basic Array Problems for Coding Interviews
337 basic Array problems from real coding interviews, each with test cases you can run online. By difficulty they split into 337 basic, 0 intermediate and 0 advanced. The companies that ask them most often are Google, Amazon, Meta, Microsoft.
Solve a few problems of each level, name the pattern after each one and revisit the ones that needed a hint a week later. Practise stating the time and space complexity and the edge cases before you code.
Coding problems
- Two Sum (Basic)
- Contains Duplicate (Basic)
- Best Time to Buy and Sell Stock (Basic)
- Move Zeroes (Basic)
- Search Insert Position (Basic)
- Maximum Product of Two Values (Basic)
- Single Number (Basic)
- Majority Element (Basic)
- Missing Number (Basic)
- Intersection of Two Arrays (Basic)
- Merge Two Sorted Arrays (Basic)
- Two Sum in a Sorted Array (Basic)
- Count Distinct Values (Basic)
- Greatest Common Divisor of an Array (Basic)
- Sort Colors (Basic)
- Remove Element (Basic)
- Remove Duplicates Keeping Order (Basic)
- Third Maximum Number (Basic)
- Max Consecutive Ones (Basic)
- Find Pivot Index (Basic)
- Running Sum of Array (Basic)
- Squares of a Sorted Array (Basic)
- Valid Mountain Array (Basic)
- Plus One (Basic)
- Sort Array by Parity (Basic)
- Concatenation of an Array (Basic)
- Sum of Unique Values (Basic)
- Maximum Sum of a Window (Basic)
- Decode XORed Array (Basic)
- Find All Missing Numbers (Basic)
- Three Consecutive Odd Values (Basic)
- Ones At Least K Apart (Basic)
- Count Negative Numbers (Basic)
- Kth Missing Positive Number (Basic)
- Find the Duplicate and Missing Number (Basic)
- Buy Two Chocolates (Basic)
- Divide Array Into Equal Pairs (Basic)
- Maximum Increasing Difference (Basic)
- Unique Number of Occurrences (Basic)
- Largest Perimeter Triangle (Basic)
- Count Pairs With a Target Sum (Basic)
- Maximum Product of Three (Basic)
- Restore a Shuffled String (Basic)
- Count Numbers With Even Digits (Basic)
- Element Appearing Over a Quarter (Basic)
- Poisoned Time Total (Basic)
- Minimum Time to Visit All Points (Basic)
- Find the Town Judge (Basic)
- Count Good Pairs (Basic)
- Maximum Ice Cream Bars (Basic)
- Circular Window Maximum (Basic)
- Rotated Array Occurrence Count (Basic)
- Minimum Platforms for Events (Basic)
- Kth Smallest Pair Distance (Basic)
- Count Pairs Divisible by K (Basic)
- Maximum Consecutive Ones With One Swap (Basic)
- Minimum Removals to Reach Target Sum (Basic)
- Chinese Remainder Solver (Basic)
- Skyline Key Points (Basic)
- Maximum Frequency After Increments (Basic)
- Longest Harmonious Subsequence (Basic)
- Maximum Weight Cut (Basic)
- Tree Distance Queries (Basic)
- Merge Two Sorted Arrays (Basic)
- Single Number (Basic)
- Number of Connected Components (Basic)
- Minimum Cost to Climb Stairs (Basic)
- Maximum Sum Subarray of Length K (Basic)
- Merge Multiple Sorted Sequences (Basic)
- LRU Cache Operations (Basic)
- Minimum Operations to Reduce X (Basic)
- Range Minimum Query Updates (Basic)
- Count Range Sums (Basic)
- Find All Ancestors in DAG (Basic)
- Maximum Path Quality (Basic)
- Maximum Sum Path Across Two Arrays (Basic)
- Count Subarrays With Median K (Basic)
- Minimum Speed to Arrive on Time (Basic)
- Minimum Time to Repair Items (Basic)
- Maximum Sum of K Disjoint Segments (Basic)
Related
Frequently asked questions
How do I get good at array problems?
Practise by level, name the pattern after you solve each problem and review the ones you needed hints for. The list is ordered so you can start with the basic ones.
Can I run array problems online here?
Yes. Each problem opens in an editor that runs your code against test cases in Java, Python, C++, Go, JavaScript and more.