Array Interview Questions and Answers: The 30 Most Asked in Product Company Interviews India 2025
The 30 most asked array interview questions at Amazon, Google, Flipkart and other product companies in India — with optimal solutions, complexity analysis and company tags.

Posted by
Shahar Banu

Reviewed by
Divyansh Dubey
Published
Array interview questions are the single largest category tested in product company hiring rounds in India — covering everything from basic traversal to complex subarray optimisation problems. If you are preparing for your first product company interview at Amazon, Google, Flipkart, or a mid-stage startup like Razorpay or CRED, arrays will appear in at least one coding round, guaranteed. This guide gives you the 30 most asked array questions from real 2024–2025 interview rounds, organised by pattern, with the naive approach, the optimal solution, time and space complexity, and which companies have asked each one recently. By the end of this guide, you will know exactly which patterns to drill, how to narrate your thinking in a live interview, and why solving 150 random Leetcode problems without pattern recognition is a strategy that stalls careers.
Why Array DSA Problems Dominate Product Company Interviews
Arrays and hashing together account for approximately 30% of all coding questions asked in product company interviews in India. That is not an estimate — it is a pattern that holds across Amazon India's online assessment data, Flipkart's HackerEarth rounds, and Google India's first-round phone screens. The reason is structural. Arrays are the foundational data structure. Every interviewer uses them to test whether a candidate understands iteration, indexing, memory layout, and optimisation trade-offs simultaneously.
Post-2024 layoffs, product companies in India have raised their DSA bar. Flipkart and Amazon India now routinely push Medium-to-Hard array problems into round one, where two years ago they would have appeared in round two. Engineers who treat arrays as "easy warm-up" problems are consistently surprised when they face a sliding window on a subarray or a two-pointer on a sorted rotated array in the first fifteen minutes of their screen. The gap between solving a problem and explaining your pattern recognition is exactly where most engineers from service companies fail.
If you are wondering how to prepare for product company interviews while working full-time, arrays are the right starting point — not because they are easy, but because mastering six array patterns gives you a template for reasoning that transfers to strings, linked lists, and even graph traversal problems. According to AmbitionBox data, software engineers at product companies in India earn ₹14–28 LPA at the 2–5 year band, compared to ₹6–10 LPA at service companies. Array mastery is one of the fastest ways to close that gap. You can explore the foundational context further in this guide on what DSA is and why it matters right now.
Key takeaway: Arrays appear in 30% of all product company coding rounds in India. Mastering the six core patterns — not grinding problems randomly — is the preparation strategy that consistently produces results.
The 6 Core Array Patterns Every Engineer Must Know
Before you look at any individual problem, you need to understand which pattern it belongs to. This is the mental model that separates engineers who solve problems methodically from those who recognise a problem only after seeing it before.
| Pattern | What It Solves | Representative Problems |
|---|---|---|
| Two Pointers | Pair-finding, palindromes, sorted array ops | Two Sum (sorted), 3Sum, Container With Most Water |
| Sliding Window | Subarray with constraint (max/min/exact) | Max sum subarray of size K, Longest subarray with sum ≤ K |
| Prefix Sum | Range sum queries, subarray sums | Subarray Sum Equals K, Count of subarrays with given XOR |
| HashMap / HashSet | Lookup, frequency counting, deduplication | Two Sum (unsorted), Longest Consecutive Sequence |
| Kadane's Algorithm | Maximum subarray problems | Maximum Subarray, Maximum Product Subarray |
| Sorting + Greedy | Interval merging, scheduling, ordering | Merge Intervals, Non-overlapping Intervals |
These six patterns cover roughly 80% of the array interview questions India's top product companies ask. The remaining 20% are hybrid problems — usually a prefix sum combined with a HashMap, or a two-pointer combined with a sort. If you want a broader view of how these patterns connect across all DSA topics, read this deep-dive on cracking product company interviews from scratch with a structured plan.
Key takeaway: Identifying the pattern within the first two minutes of reading a problem statement is the single most important interview skill. Pattern-first thinking beats brute-force memorisation every time.
The 30 Most Asked Array Interview Questions — Organised by Pattern Tier
Tier 1 — Easy (Foundation)
These problems appear in online assessments and round-one screens. They test whether you understand basic iteration, indexing, and the difference between O(n²) and O(n).
1. Two Sum *Problem:* Given an unsorted array, find two indices whose values sum to a target. *Naive:* Nested loop — O(n²) time, O(1) space. *Optimal:* HashMap — store each element's index as you iterate. O(n) time, O(n) space. *Companies:* Amazon India, Flipkart, Microsoft India (asked in 2024 OA rounds).
2. Best Time to Buy and Sell Stock *Problem:* Given prices array, find the maximum profit from one buy-sell transaction. *Naive:* Nested loop comparing every pair — O(n²). *Optimal:* Track running minimum price; compute profit at each step — O(n) time, O(1) space. *Companies:* Google India, Paytm, Uber India.
3. Contains Duplicate *Problem:* Return true if any element appears more than once. *Naive:* Sort, then check adjacent — O(n log n) time. *Optimal:* HashSet — O(n) time, O(n) space. *Companies:* Freshworks, Zoho, Razorpay screening rounds.
4. Move Zeroes *Problem:* Move all zeroes to the end without changing the order of non-zero elements. *Naive:* Create a new array — O(n) time, O(n) space. *Optimal:* Two-pointer in-place swap — O(n) time, O(1) space. *Companies:* Flipkart, Swiggy (online assessment 2024).
5. Maximum Subarray (Kadane's Algorithm) *Problem:* Find the contiguous subarray with the largest sum. *Naive:* All subarrays — O(n²) or O(n³). *Optimal:* Kadane's — track running sum, reset when negative — O(n) time, O(1) space. *Companies:* Amazon India, Microsoft India, Google India.
6. Plus One *Problem:* Given a number as a digit array, return it incremented by one. *Optimal:* Handle carry from the last digit — O(n) time, O(1) space. *Companies:* Oracle India, Infosys Product Engineering.
7. Single Number *Problem:* Every element appears twice except one. Find it. *Naive:* HashMap count — O(n) time, O(n) space. *Optimal:* XOR all elements — duplicate pairs cancel out — O(n) time, O(1) space. *Companies:* Walmart Global Tech India, PhonePe.
8. Intersection of Two Arrays *Problem:* Find common elements between two arrays. *Optimal:* HashSet on first array, iterate second — O(n + m) time, O(n) space. *Companies:* Zoho, Freshworks.
9. Find Missing Number *Problem:* Array of n distinct numbers in range [0, n]. Find the missing one. *Naive:* Sort and scan — O(n log n). *Optimal:* Expected sum minus actual sum — O(n) time, O(1) space. XOR approach also valid. *Companies:* Amazon India OA, Flipkart screening.
10. Rotate Array *Problem:* Rotate array right by k steps in-place. *Naive:* Extra array — O(n) time, O(n) space. *Optimal:* Three-reversal approach — O(n) time, O(1) space. *Companies:* Microsoft India, Adobe India.
Tier 2 — Medium (Core Interview Problems)
This is where most engineers from service companies struggle. These problems require pattern recognition, not just syntax. This is also where the reason service engineers fail MAANG DSA rounds becomes very concrete.
11. 3Sum *Problem:* Find all unique triplets that sum to zero. *Naive:* Three nested loops — O(n³). *Optimal:* Sort + two-pointer for each element — O(n²) time, O(1) auxiliary space. *Companies:* Google India, Atlassian, Meesho.
12. Product of Array Except Self *Problem:* Return array where each element is the product of all others. No division allowed. *Naive:* For each index, multiply all others — O(n²). *Optimal:* Left-pass and right-pass prefix products — O(n) time, O(1) space (excluding output). *Companies:* Amazon India, Google India, Swiggy backend rounds.
13. Subarray Sum Equals K *Problem:* Count subarrays with sum equal to K. *Naive:* All subarrays — O(n²). *Optimal:* Prefix sum + HashMap — O(n) time, O(n) space. Track frequency of prefix sums seen so far. *Companies:* Amazon India, Flipkart, Microsoft India (frequently asked in 2024–2025).
14. Longest Consecutive Sequence *Problem:* Find the length of the longest sequence of consecutive integers. *Naive:* Sort, then scan — O(n log n). *Optimal:* HashSet — start counting only when n-1 is not in set — O(n) time, O(n) space. *Companies:* Google India, CRED, Razorpay.
15. Maximum Product Subarray *Problem:* Find contiguous subarray with largest product. *Naive:* All subarrays — O(n²). *Optimal:* Track both current maximum and minimum (negatives flip sign) — O(n) time, O(1) space. *Companies:* Amazon India, Uber India.
16. Find Minimum in Rotated Sorted Array *Problem:* Binary search for minimum in a rotated sorted array. *Naive:* Linear scan — O(n). *Optimal:* Modified binary search — O(log n) time, O(1) space. *Companies:* Google India, Flipkart, PhonePe engineering rounds.
17. Container With Most Water *Problem:* Given heights array, find two lines that form the container holding the most water. *Naive:* All pairs — O(n²). *Optimal:* Two-pointer from both ends, move the shorter side inward — O(n) time, O(1) space. *Companies:* Amazon India, Microsoft India, Paytm.
18. Jump Game *Problem:* Determine if you can reach the last index given jump lengths. *Naive:* Recursion / DP — O(n²). *Optimal:* Greedy — track maximum reachable index — O(n) time, O(1) space. *Companies:* Flipkart, InMobi, Walmart Global Tech India.
19. Merge Intervals *Problem:* Merge all overlapping intervals. *Naive:* Compare all pairs — O(n²). *Optimal:* Sort by start time + linear merge — O(n log n) time, O(n) space. *Companies:* Google India, Amazon India, Swiggy.
20. Spiral Matrix *Problem:* Return all elements of a matrix in spiral order. *Optimal:* Four-boundary pointer approach — O(m×n) time, O(1) auxiliary space. *Companies:* Microsoft India, Adobe India, Oracle India.
For problems like sliding window and two-pointer, which underpin Questions 11, 13, and 17, a dedicated pattern breakdown is available at the FutureJobs blog on hidden DSA patterns at Flipkart and Uber.
Tier 3 — Hard (Differentiator Problems)
These appear in round two and three at Amazon, Google India, and Flipkart for SDE-2 and SDE-3 roles. Solving one of these cleanly in an interview is a strong positive signal.
21. Trapping Rain Water *Problem:* Given heights, compute how much rainwater can be trapped. *Naive:* For each index, find max-left and max-right — O(n²). *Optimal:* Two-pointer — O(n) time, O(1) space. Track left-max and right-max simultaneously. *Companies:* Google India, Amazon India, Flipkart (consistently top-5 hard arrays).
22. Sliding Window Maximum *Problem:* Maximum in every window of size K in array. *Naive:* Scan each window — O(n×k). *Optimal:* Monotonic deque — O(n) time, O(k) space. *Companies:* Amazon India, Meesho, Razorpay.
23. Minimum Window Substring (Array variant) *Problem:* Find minimum subarray containing all required elements. *Optimal:* Sliding window with frequency map — O(n) time, O(k) space. *Companies:* Google India, Microsoft India.
24. Largest Rectangle in Histogram *Problem:* Find the area of the largest rectangle in a histogram. *Naive:* All bar pairs — O(n²). *Optimal:* Monotonic stack — O(n) time, O(n) space. *Companies:* Amazon India, Flipkart, PhonePe.
25. First Missing Positive *Problem:* Find the smallest missing positive integer in O(n) time and O(1) space. *Naive:* HashSet — O(n) time, O(n) space. *Optimal:* Index as hash — place each number at its "correct" index — O(n) time, O(1) space. *Companies:* Google India, Amazon India SDE-2 rounds.
26. Count of Subarrays with XOR Equal to K *Problem:* Count subarrays whose XOR equals target K. *Optimal:* Prefix XOR + HashMap — O(n) time, O(n) space. Same structure as Subarray Sum Equals K. *Companies:* Flipkart, Amazon India.
27. Maximum Sum of Two Non-overlapping Subarrays *Problem:* Find two non-overlapping subarrays of given lengths with maximum total sum. *Optimal:* Prefix sums + two-pass DP — O(n) time, O(n) space. *Companies:* Google India, LinkedIn India.
28. Find All Duplicates in an Array *Problem:* Array contains n integers where each appears once or twice. Find all duplicates in O(n) and O(1) space. *Optimal:* Negate value at index as visited marker — O(n) time, O(1) space. *Companies:* Amazon India, Microsoft India.
29. Longest Subarray with Sum Divisible by K *Problem:* Find the longest subarray whose sum is divisible by K. *Optimal:* Prefix sum modulo K + HashMap of first occurrence — O(n) time, O(k) space. *Companies:* Amazon India, Flipkart, Paytm.
30. 4Sum *Problem:* Find all unique quadruplets summing to target. *Naive:* Four nested loops — O(n⁴). *Optimal:* Sort + two outer loops + two-pointer for inner pair — O(n³) time, O(1) auxiliary space. *Companies:* Google India, Meesho, CRED engineering rounds.
Only 6 Seats Left — Cohort 3
Array and HashMap Combinations — The Most Common Hybrid Pattern
The most frequently missed insight in array interview prep is that HashMap is not a separate topic from arrays — it is an accelerant for array problems. The question "how do I get this from O(n²) to O(n)?" is almost always answered by introducing a HashMap to store something you would otherwise search for in a nested loop.
The canonical example is Two Sum. The naive solution scans the array for each element's complement — O(n²). The optimal solution stores each element in a HashMap as you iterate and checks for the complement in O(1) — giving you O(n) overall. This exact mental model — "can I store a computation I'll need later in a HashMap?" — applies directly to Subarray Sum Equals K (store prefix sum frequencies), Longest Consecutive Sequence (store all numbers, then check for sequence starts), and Count of Subarrays with XOR Equal to K (store prefix XOR frequencies).
The pattern to internalise: whenever you find yourself searching inside an inner loop, ask whether a HashMap can replace that search with O(1) lookup. This single habit will improve your performance on at least 8 of the 30 problems listed above.
Amazon interviewers in India specifically look for whether you arrive at the HashMap optimisation independently — without being prompted. The signal they are looking for is not "did the candidate know the trick" but "did the candidate reason their way to it from first principles." That reasoning narration — saying "I see I'm doing repeated lookups, which suggests I should pre-store values in a HashMap" — is what earns the hire signal in borderline cases.
Key takeaway: HashMap is the most common optimisation tool for array problems. When your naive solution has a nested loop, ask whether a HashMap eliminates the inner search. This pattern alone covers 8 of the 30 most asked array questions.
How to Think Through Array Problems in a Live Interview
Most engineers who fail product company coding rounds do not fail because they cannot solve the problem. They fail because they go silent, start coding immediately, or ask no questions. Here is a narration script — not a template, but a mental track to run in every array interview.
Step 1 — Restate the problem in your own words (30 seconds) Say: "Let me make sure I understand. I have an input array of integers and I need to find... Is that right?" This buys thinking time and catches ambiguity before you write code.
Step 2 — Identify constraints and edge cases aloud (60 seconds) Ask: "Can the array be empty? Can it contain negative numbers? Is it sorted? Can values repeat?" For array DSA problems, these four questions eliminate 80% of edge-case bugs before you write line one.
Step 3 — State the pattern you are applying Say: "This looks like a sliding window problem — I have a contiguous subarray constraint with a size K, so I'll maintain a window and update it in O(1) per step rather than recomputing." Naming the pattern tells the interviewer you have structure.
Step 4 — State the naive approach and complexity first Say: "A brute-force would be two nested loops giving me O(n²) time and O(1) space. But I think I can do better." Never skip this. It shows you understand the baseline and are improving on it deliberately.
Step 5 — Walk through the optimal approach before coding Trace through a small example with actual values. Say: "With input [2, 7, 11, 15] and target 9, my HashMap would look like: I see 2, store it. I see 7, check if 9-7=2 is in the map — yes — so indices 0 and 1 are the answer." This prevents bugs and demonstrates communication clarity.
FutureJobs mock interview sessions specifically drill this narration track for array pattern problems. Engineers in the DSA & System Design with AI program report that after five structured mock sessions, the narration becomes automatic — the part of the interview that previously caused the most anxiety becomes a mechanical advantage. You can read about how to build this structured daily practice in this guide on studying DSA with only one hour a day.
Key takeaway: Your narration is scored as heavily as your code in product company interviews. Engineers who name the pattern, state the naive approach, and trace an example before coding consistently outperform engineers who code faster but communicate less.
How DSA & System Design with AI Program Can Help You
If you are 1.5 years into your career and have solved 150 Leetcode problems without a single interview callback, the problem is almost certainly structure — not volume. Grinding random problems without pattern recognition is the most common and most costly preparation mistake early-career engineers make. The FutureJobs DSA & System Design with AI program is built specifically to fix this.
The program runs on an evening and weekend schedule — 15–20 hours per week for five months — which means you prepare without quitting your current job. The curriculum covers all six array patterns, plus DSA fundamentals, system design (HLD and LLD), and a Prompt Engineering module that prepares you for AI-era product roles. You get a 1:1 FAANG mentor throughout — not a TA, but an engineer who has cleared Google or Amazon's interview process and can tell you when you are ready, which is the exact gap you are probably feeling right now.
The pay-after-placement model is the structural differentiator. You pay ₹4,999/month during the program — effective upfront investment of roughly ₹5,000 — and complete payment only after you receive and accept a job offer. FutureJobs is structurally different from Scaler or AlmaBetter in one key way: the pay-after-placement model means the program's incentive is aligned with your outcome, not your enrollment. The program covers 240+ hours of live classes, mock interview sessions with pattern narration drills, and access to FAANG mentors who have made the exact service-to-product transition you are targeting. Over 700 engineers enrolled in the DSA program this month alone.
Only 12 Seats Left — Cohort 3
Frequently Asked Questions
What array questions does Amazon India ask in interviews?
Amazon India asks array questions across all difficulty tiers in its online assessment and SDE phone screens. The most frequently appearing problems in 2024–2025 rounds include Two Sum, Subarray Sum Equals K, Trapping Rain Water, Maximum Product Subarray, and Sliding Window Maximum. Amazon interviewers consistently test whether candidates arrive at the HashMap optimisation independently and whether they verify edge cases — empty arrays, negative values, and single-element inputs — before writing code.
How many array problems do I need to solve to be ready for MAANG interviews?
You do not need to solve more than 60–80 well-chosen array problems to be interview-ready for MAANG and top Indian product companies in 2026. The number is far less important than pattern coverage. If your 60 problems span all six core patterns — two pointers, sliding window, prefix sum, HashMap, Kadane's, and sorting plus greedy — and you can solve each one without hints, you are ready. Engineers in FutureJobs' DSA program consistently move from 150 random problems with no pattern clarity to 60 structured problems with interview-level narration confidence within 8–10 weeks of structured practice.
What is the most common array pattern asked in product company interviews?
The most common array pattern in product company interviews in India is the HashMap or HashSet lookup pattern, which appears directly or as the optimising layer in roughly 40% of all array questions. The sliding window pattern is the second most frequent, appearing in subarray-with-constraint problems at Google India, Amazon India, and Flipkart. If you can solve Two Sum, Subarray Sum Equals K, and Longest Consecutive Sequence cleanly and explain your HashMap reasoning, you have covered the highest-frequency pattern cluster in array DSA interview prep.
Can I prepare for array interviews while working full-time at a service company?
Yes — and engineers preparing for product company interviews from service companies in India do it every day. The practical requirement is roughly 1–1.5 hours on weekdays and 3–4 hours on weekends, which is achievable from Chennai, Hyderabad, Pune, or any city without relocation. The key is working from a structured pattern curriculum rather than random Leetcode grinding. Engineers who study one array pattern per week — drilling 8–10 problems per pattern — are consistently interview-ready within 8–12 weeks. The 2026 playbook for switching from service to product company covers the full preparation roadmap including timeline and daily study structure.
Does DSA still matter in 2026 when GitHub Copilot can generate array code?
DSA matters more in 2026 than it did in 2022, specifically because AI tools have flooded the market with engineers who can produce working code without understanding it. Product companies in India — Amazon, Google, Flipkart, Razorpay, CRED — have responded by raising the bar on problem-solving communication, not lowering it. GitHub Copilot can generate a two-pointer solution. It cannot explain to an interviewer why the two-pointer approach works, what the time complexity is, and what edge cases fail. That reasoning — which is entirely human — is what product company interviews now screen for most explicitly.
Is 1.5 years of experience enough to target product companies in India?
Yes — product companies in India including Razorpay, Swiggy, Meesho, Freshworks, and Zoho regularly hire engineers with 1–3 years of experience for junior SDE roles at ₹12–18 LPA. Amazon India and Flipkart also hire at the SDE-1 level with no college-tier filter at the DSA screening stage. The requirement is not years of experience — it is demonstrable pattern-level DSA competency and the ability to communicate your solution thinking clearly. Engineers with 1.5 years who prepare with structure — covering the six core patterns, doing mock interviews with narration practice, and targeting appropriate roles — clear their first product company offer within three to six months of focused preparation.
Final Thoughts
You now have the full architecture of array interview preparation for product company roles in India — the six core patterns, the 30 most asked problems organised by difficulty and company, the HashMap optimisation principle, and the narration script that tells interviewers you know what you are doing before you write a single line of code.
The engineers who clear product company coding rounds in India in 2026 are not the ones who solved the most problems. They are the ones who solved the right problems in the right order, built a pattern vocabulary, and practised narrating their thinking until it became automatic. That is a replicable process — not a talent.
If you are 1.5 years in, earning ₹4.5 LPA, and watching your NIT Trichy batchmates land at Google and Amazon — the gap is not your experience level. The gap is structure. You have the raw ability. What you need is a preparation system that tells you what to study, in what order, at what depth, and when you are ready. That is exactly what structured DSA preparation — with mentor feedback and mock interviews — provides.
The next step is simple: pick one pattern from the six listed above. Drill 8–10 problems from that pattern this week. Then move to the next. If you want mentor feedback on your narration and pattern recognition from someone who has sat on both sides of the interview table, the DSA & System Design with AI program at FutureJobs gives you that — with a pay-after-placement model that removes the financial risk.
