Data Structures and Algorithms
Arrays Interview Roadmap: 138 Questions Mapped by Technique
Master 138 essential array most asket interview questions categorized by algorithmic techniques like sliding window, two pointers, and prefix sum.

Hover to zoomCracking top product company interview loops requires abandoning the habit of solving random LeetCode problems. When building an effective arrays interview roadmap, memorized solutions crumble without an underlying structural framework when an interviewer twists a standard constraint.
Why Grouping Array Questions by Technique Works
If you are preparing in Java, we teach this extensively in our Java DSA Course. You can also expand your preparation beyond arrays by checking out our Queue Interview Roadmap: Grouped by Patterns and LeetCode Links and the String Interview Roadmap: 66 Questions Grouped by Technique.
Arrays are the foundation of data structures. However, because they are simple, interviewers love to layer complex algorithmic demands on top of them. Instead of viewing these as 138 individual hurdles, we can categorize them into 8 core techniques. Mastering these 8 techniques gives you the mental framework to solve almost any array-based question.
| Rote Memorization | Pattern-Based Roadmap | |
|---|---|---|
| Learning Efficiency | Low. You try to remember 100+ unique solutions. | High. You learn 8 templates that apply to 138 questions. |
| Adaptability | Fails when the interviewer changes constraints. | Succeeds because you understand the core mechanics. |
| Time Complexity Focus | Often ends in accidental O(N^2) brute force. | Naturally guides you to O(N) or O(N log N) optimizations. |
Technique 1: The Two Pointers Pattern
public class TwoPointersDemo {
public static int[] twoSum(int[] numbers, int target) {
int left = 0, right = numbers.length - 1;
while (left < right) {
int sum = numbers[left] + numbers[right];
if (sum == target) {
return new int[] { left + 1, right + 1 };
} else if (sum < target) {
left++;
} else {
right--;
}
}
return new int[0];
}
}Here are the key Two Pointer questions you must master:
- Two Sum II - Input Array Is Sorted (LeetCode 167)
- 3Sum (LeetCode 15)
- Container With Most Water (LeetCode 11)
- Valid Palindrome (LeetCode 125)
- Remove Duplicates from Sorted Array (LeetCode 26)
- Merge Sorted Array (LeetCode 88)
- Squares of a Sorted Array (LeetCode 977)
- Sort Colors (LeetCode 75)
- Trapping Rain Water (LeetCode 42)
- Move Zeroes (LeetCode 283)
- Assign Cookies (LeetCode 455)
- Compare Version Numbers (LeetCode 165)
- Reverse String (LeetCode 344)
- Interval List Intersections (LeetCode 986)
- Bag of Tokens (LeetCode 948)
- Boats to Save People (LeetCode 881)
- Next Permutation (LeetCode 31)
- Rotate Array (LeetCode 189)
- Minimize Maximum Pair Sum in Array (LeetCode 1877)
- Partition Labels (LeetCode 763)
Technique 2: Sliding Window (Fixed and Variable)
- Maximum Average Subarray I (LeetCode 643)
- Longest Substring Without Repeating Characters (LeetCode 3)
- Minimum Size Subarray Sum (LeetCode 209)
- Permutation in String (LeetCode 567)
- Longest Repeating Character Replacement (LeetCode 424)
- Sliding Window Maximum (LeetCode 239)
- Minimum Window Substring (LeetCode 76)
- Max Consecutive Ones III (LeetCode 1004)
- Fruit Into Baskets (LeetCode 904)
- Subarrays with K Different Integers (LeetCode 992)
- Find All Anagrams in a String (LeetCode 438)
- Maximum Number of Vowels in a Substring of Given Length (LeetCode 1456)
- Number of Subarrays of Size K and Average Greater than or Equal to Threshold (LeetCode 1343)
- Longest Subarray of 1's After Deleting One Element (LeetCode 1493)
- Frequency of the Most Frequent Element (LeetCode 1838)
- Maximum Points You Can Obtain from Cards (LeetCode 1423)
- Get Equal Substrings Within Budget (LeetCode 1208)
- Replace the Substring for Balanced String (LeetCode 1234)
- Shortest Subarray with Sum at Least K (LeetCode 862)
- Count Number of Nice Subarrays (LeetCode 1248)
Technique 3: Prefix Sum and Running Totals
Prefix sums allow you to perform range sum queries in O(1) constant time after an O(N) precomputation. When combined with a HashMap, this technique becomes an incredibly powerful tool for finding subarrays that sum up to a specific target.
- Range Sum Query - Immutable (LeetCode 303)
- Subarray Sum Equals K (LeetCode 560)
- Find Pivot Index (LeetCode 724)
- Contiguous Array (LeetCode 525)
- Subarray Sums Divisible by K (LeetCode 974)
- Product of Array Except Self (LeetCode 238)
- Minimum Value to Get Positive Step by Step Sum (LeetCode 1413)
- Find the Middle Index in Array (LeetCode 1991)
- Running Sum of 1d Array (LeetCode 1480)
- Continuous Subarray Sum (LeetCode 523)
- Grid Game (LeetCode 2017)
- Maximum Sum Score of Array (LeetCode 2219)
- Find the Student that Will Replace the Chalk (LeetCode 1894)
- Car Pooling (LeetCode 1094)
- Corporate Flight Bookings (LeetCode 1109)
- Shifting Letters (LeetCode 848)
- Can Place Flowers (LeetCode 605)
- Maximum Size Subarray Sum Equals k (LeetCode 325)
- Number of Ways to Split Array (LeetCode 2270)
- Left and Right Sum Differences (LeetCode 2574)
Technique 4: Sorting and Greedy Approaches
Sometimes, the easiest way to find a pattern in an array is to sort it first. Sorting reduces the complexity of searching and pairing. When combined with a greedy strategy, it allows you to make locally optimal choices that lead to a globally optimal solution.
- Merge Intervals (LeetCode 56)
- Insert Interval (LeetCode 57)
- Non-overlapping Intervals (LeetCode 435)
- Meeting Rooms (LeetCode 252)
- Meeting Rooms II (LeetCode 253)
- Queue Reconstruction by Height (LeetCode 406)
- Minimum Number of Arrows to Burst Balloons (LeetCode 452)
- Largest Number (LeetCode 179)
- K Closest Points to Origin (LeetCode 973)
- Top K Frequent Elements (LeetCode 347)
- Kth Largest Element in an Array (LeetCode 215)
- Sort an Array (LeetCode 912)
- Maximum Units on a Truck (LeetCode 1710)
- Array Partition (LeetCode 561)
- Gas Station (LeetCode 134)
- Candy (LeetCode 135)
- Wiggle Sort (LeetCode 280)
- Wiggle Sort II (LeetCode 324)
- H-Index (LeetCode 274)
- Majority Element (LeetCode 169)
Technique 5: Binary Search on Arrays
Do not limit Binary Search to simple target lookups in sorted arrays. You can also use it to search for answers in a bounded range (Binary Search on Answer) or to find structural pivot points in rotated arrays.
- Binary Search (LeetCode 704)
- Search in Rotated Sorted Array (LeetCode 33)
- Find Minimum in Rotated Sorted Array (LeetCode 153)
- Search a 2D Matrix (LeetCode 74)
- Find Peak Element (LeetCode 162)
- First Bad Version (LeetCode 278)
- Search Insert Position (LeetCode 35)
- Find First and Last Position of Element in Sorted Array (LeetCode 34)
- Capacity To Ship Packages Within D Days (LeetCode 1011)
- Koko Eating Bananas (LeetCode 875)
- Peak Index in a Mountain Array (LeetCode 852)
- Median of Two Sorted Arrays (LeetCode 4)
- Single Element in a Sorted Array (LeetCode 540)
- Search in Rotated Sorted Array II (LeetCode 81)
- Find Minimum in Rotated Sorted Array II (LeetCode 154)
- Search a 2D Matrix II (LeetCode 240)
- Arranging Coins (LeetCode 441)
- Valid Perfect Square (LeetCode 367)
- Heaters (LeetCode 475)
- Split Array Largest Sum (LeetCode 410)
Technique 6: Matrix and 2D Arrays Traversal
A 2D array is simply an array of arrays. Matrix problems test your ability to handle indices carefully, manage boundaries, and execute structural transformations like rotations and spiral traversals.
- Spiral Matrix (LeetCode 54)
- Rotate Image (LeetCode 48)
- Set Matrix Zeroes (LeetCode 73)
- Diagonal Traverse (LeetCode 498)
- Game of Life (LeetCode 289)
- Valid Sudoku (LeetCode 36)
- Flood Fill (LeetCode 733)
- Island Perimeter (LeetCode 463)
- Spiral Matrix II (LeetCode 59)
- Reshape the Matrix (LeetCode 566)
- Matrix Diagonal Sum (LeetCode 1572)
- Transpose Matrix (LeetCode 867)
- Toeplitz Matrix (LeetCode 766)
- Shift 2D Grid (LeetCode 1260)
- Lucky Numbers in a Matrix (LeetCode 1380)
- Count Negative Numbers in a Sorted Matrix (LeetCode 1351)
- Special Positions in a Binary Matrix (LeetCode 1582)
- Flipping an Image (LeetCode 832)
- Cells with Odd Values in a Matrix (LeetCode 1252)
- Where Will the Ball Fall (LeetCode 1706)
Technique 7: Monotonic Stack and Queue in Arrays
When you need to find the 'next greater element' or 'next smaller element' for every item in an array, a nested loop is too slow. A Monotonic Stack keeps elements in a sorted order (increasing or decreasing) to solve these problems in linear time.
- Next Greater Element I (LeetCode 496)
- Next Greater Element II (LeetCode 503)
- Daily Temperatures (LeetCode 739)
- Largest Rectangle in Histogram (LeetCode 84)
- Online Stock Span (LeetCode 901)
- Maximal Rectangle (LeetCode 85)
- Sum of Subarray Minimums (LeetCode 907)
- Remove Duplicate Letters (LeetCode 316)
- Smallest Subsequence of Distinct Characters (LeetCode 1081)
- 132 Pattern (LeetCode 456)
- Beautiful Towers I (LeetCode 2865)
- Beautiful Towers II (LeetCode 2866)
- Maximum Width Ramp (LeetCode 962)
- Car Fleet (LeetCode 853)
- Asteroid Collision (LeetCode 735)
- Remove K Digits (LeetCode 402)
- Shortest Unsorted Continuous Subarray (LeetCode 581)
- Minimum Add to Make Parentheses Valid (LeetCode 921)
Technique 8: Frequency Tracking and Hashing
Trading space for time is a core tenet of algorithm design. By using HashMaps, HashSets, or fixed-size frequency arrays, you can track occurrences, find duplicates, and resolve lookups in O(1) time.
- Two Sum (LeetCode 1)
- Contains Duplicate (LeetCode 217)
- Contains Duplicate II (LeetCode 219)
- Longest Consecutive Sequence (LeetCode 128)
- First Missing Positive (LeetCode 41)
- Find All Duplicates in an Array (LeetCode 442)
- Find All Numbers Disappeared in an Array (LeetCode 448)
- Intersection of Two Arrays (LeetCode 349)
- Intersection of Two Arrays II (LeetCode 350)
- Valid Anagram (LeetCode 242)
- Group Anagrams (LeetCode 49)
- Ransom Note (LeetCode 383)
- Unique Number of Occurrences (LeetCode 1207)
- Find players with zero or one losses (LeetCode 2225)
- Subarray Sums Divisible by K (LeetCode 974)
- Continuous Subarray Sum (LeetCode 523)
- Determine if Two Strings Are Close (LeetCode 1657)
- Custom Sort String (LeetCode 791)
- Find the Difference of Two Arrays (LeetCode 2215)
- Least Number of Unique Integers after K Removals (LeetCode 1481)
Do not try to solve all 138 questions in one week. Pick one technique at a time from this arrays interview roadmap and focus on it for a few days. Solve the easy problems first to master the template, then tackle medium and hard variations. For a broader view, explore the DSA Roadmap: Master Algorithms Roadmap along with our Data Structures and Algorithms using Java program.
By learning to recognize these core structures, you will walk into your next technical interview with absolute confidence. For a broader view of coding preparation, explore our Placement Array Roadmap: The Ultimate Coding Interview Guide and our Data Structures and Algorithms using Java program.
