Data Structures Interview Questions and Answers: The Complete 2025 Guide for Working Engineers
The complete data structures interview guide for product company rounds in India — Arrays, Linked Lists, Trees, Graphs, Heaps, HashMaps — with real company tags and complexity analysis.

Posted by
Shahar Banu

Reviewed by
Divyansh Dubey
Published
You write solid backend code every day. You understand Java, you know how APIs work, and three years at a service company have made you technically dependable. But when you sit down with LeetCode on a Saturday morning and stare at a medium-level array problem, something breaks. Your brain freezes. You know the answer is somewhere in your head — but under pressure, you can't find it fast enough.
That's the exact gap between writing good code and cracking a product company interview. And it's not a talent gap. It's a preparation structure gap.
This guide covers the data structures interview questions India's top product companies actually ask in 2025 — not the full 10,000-problem ocean of GeeksForGeeks, but the 8 patterns and core data structures that Amazon India, Google India, Flipkart, and Swiggy actually test. By the end of this guide, you'll know exactly which questions to prepare, how interviewers think about each data structure, and how to explain your solutions clearly under pressure.
How This Guide Is Organised
Each data structure section below follows the same format: a plain-language definition, a real-world analogy that makes the concept stick, the interview-relevant implementation note, Big O notation for time and space complexity, and the specific companies that most frequently ask each question type. This is the engineer-to-engineer transfer of real interview knowledge — not a textbook summary.
Before diving in, here is the anchor definition you'll refer back to throughout:
A data structure is a way of organising data in computer memory so it can be read and modified efficiently. An algorithm is the step-by-step procedure that operates on that data. Together, DSA — Data Structures and Algorithms — is the technical discipline that every product company interview in India is built around. The product company interview is not testing whether you know Java or Python. It's testing whether you can choose the right data structure for a constraint-heavy problem and implement a correct solution within 30–45 minutes. That distinction changes how you prepare.
If you're just starting out and want a solid foundation first, read What is DSA and why now is the right time before continuing here.
Array and String Questions — The 10 Most Asked
Arrays are the most tested data structure in product company interviews across India, consistently appearing in every first technical round at Amazon India, Google India, Microsoft India, and Flipkart.
What it is: An array is a contiguous block of memory that stores elements of the same type, indexed from zero. A string is an array of characters. The reason arrays dominate interviews is that they're the simplest structure to manipulate, yet they expose your ability to think about two-pointer patterns, sliding windows, prefix sums, and in-place modifications — all within O(n) time.
Real-world analogy: Think of a spreadsheet row. Every cell has a fixed position. You can jump to any cell directly — that's O(1) random access. But inserting a new cell in the middle means shifting everything to the right, which is O(n).
The 10 questions product companies actually ask:
1. Two Sum — Find two indices that add to a target. Use a HashMap for O(n) time. Amazon India asks this in nearly every first screening. If the array is sorted, the two-pointer approach gives O(1) space — but only when the array is sorted.
2. Maximum Subarray (Kadane's Algorithm) — Find the contiguous subarray with the largest sum. O(n) time, O(1) space. Swiggy and Flipkart backend rounds use this frequently.
3. Merge Intervals — Given a list of intervals, merge overlapping ones. Sort by start time first: O(n log n). Google India uses interval problems to test sorting intuition.
4. Product of Array Except Self — No division allowed. Use prefix and suffix product arrays: O(n) time, O(n) space (or O(1) extra space with output array trick). Microsoft India asks this regularly.
5. Trapping Rain Water — The classic two-pointer or monotonic stack approach. O(n) time, O(1) space. Amazon and Goldman Sachs both use this.
6. Longest Substring Without Repeating Characters — Sliding window with a HashSet. O(n) time. Every company that tests strings will ask this or a close variant.
7. Rotate Array by K Positions — Reverse the whole array, then reverse subarrays. O(n) time, O(1) space. A favourite at Walmart Labs India and Oracle India.
8. Find Duplicate in Array — Floyd's cycle detection in O(n) time, O(1) space. Meesho and Razorpay have used this exact question.
9. Container with Most Water — Two pointers, O(n). Tests whether you can articulate why greedy works here.
10. Anagram Detection / Group Anagrams — Sort each string as a key or use character frequency arrays. O(n × k log k) where k is string length.
Key takeaway: The sliding window and two-pointer patterns together cover at least 6 of the top 10 array questions. Master those two before anything else. For a deeper dive, see the 30 most asked array interview questions for product companies India.
Linked List Questions — The 8 Most Asked
What it is: A linked list is a sequence of nodes where each node stores a value and a pointer to the next node. Unlike arrays, linked lists do not occupy contiguous memory — insertion and deletion at any point is O(1) if you have the pointer, but random access is O(n) because you must traverse from the head.
Real-world analogy: A train. Each compartment is connected to the next. To reach compartment 7, you board at compartment 1 and walk through each one. You can't jump. But you can detach and reattach compartments in the middle without touching the rest.
The 8 questions companies ask:
1. Reverse a Linked List — Iterative: O(n) time, O(1) space. Recursive: O(n) space for call stack. Amazon India asks the iterative version specifically and will ask you to reverse in groups of k.
2. Detect a Cycle — Floyd's Algorithm — Use slow and fast pointers. Slow moves one step, fast moves two. If they meet, there's a cycle. O(n) time, O(1) space. Google India tests the follow-up: find where the cycle starts.
3. Merge Two Sorted Lists — Iteratively compare heads. O(n + m) time. Flipkart uses this as a warm-up problem before harder tree questions.
4. Find the Middle of a Linked List — Fast and slow pointer again. When fast reaches the end, slow is at the middle. O(n) time, O(1) space.
5. Remove Nth Node from End — Two-pointer with a gap of n nodes. One pass: O(n) time, O(1) space. Microsoft India asks this with edge cases — empty list, n = length.
6. LRU Cache Implementation — Doubly linked list + HashMap. O(1) get and put. This is a system design-level linked list question. Amazon, Swiggy, and PhonePe all ask it.
7. Flatten a Multilevel Doubly Linked List — Recursive or iterative. O(n) time. Seen at Adobe India and Atlassian India.
8. Intersection of Two Linked Lists — Two-pointer: traverse both lists, switch heads when one reaches the end. O(n + m) time, O(1) space.
Insider knowledge signal: Amazon interviewers in India specifically use LRU Cache to probe whether you know when to reach for a doubly linked list versus a singly linked list. If you explain only the HashMap portion, you'll lose points. The doubly linked list enables O(1) deletion from the middle — that's the answer they're waiting for.
Only 5 Seats Left — Cohort 3
Stack and Queue Questions — The 6 Most Asked
What it is: A stack is a Last-In-First-Out (LIFO) structure — like a pile of plates. A queue is First-In-First-Out (FIFO) — like a line at a bank. In interviews, stacks are most commonly used for expression evaluation, backtracking, and the powerful monotonic stack pattern. Queues appear in BFS graph traversal and in designing rate limiters.
Real-world analogy for stacks: Your browser's back button. Every page you visit is pushed onto a stack. Pressing back pops the most recent one.
The 6 questions companies ask:
1. Valid Parentheses — Push opening brackets, pop on closing. O(n) time, O(n) space. Every company asks this. Google India uses it as a 5-minute warm-up.
2. Daily Temperatures (Monotonic Stack) — For each day, find the next warmer day. Monotonic decreasing stack: O(n) time, O(n) space. Flipkart and Uber India have both asked monotonic stack variants. See how monotonic stack and queue problems appear in Flipkart and Uber interviews.
3. Min Stack — Design a stack that returns the minimum in O(1). Use two stacks: one for values, one for minimums. Amazon India loves this question.
4. Evaluate Reverse Polish Notation — Operand → push. Operator → pop two, compute, push result. O(n) time. Microsoft India uses this to test stack mechanics under constraint.
5. Implement Queue Using Two Stacks — Push to stack1. For dequeue, transfer stack1 to stack2 if stack2 is empty. Amortised O(1) per operation.
6. Sliding Window Maximum — Use a deque (monotonic decreasing) to track max in each window of size k. O(n) time. Google India asks this at the SDE-2 level.
Key takeaway: The monotonic stack pattern is the most underestimated pattern in Indian product company interviews. Engineers who learn it specifically for Flipkart and Uber rounds report seeing it in 3–4 different questions during the same interview loop.
Tree and BST Questions — The 8 Most Asked
What it is: A binary tree is a hierarchical structure where each node has at most two children — left and right. A Binary Search Tree (BST) adds an ordering property: every node in the left subtree is smaller than the root, every node in the right subtree is larger. This ordering makes search, insertion, and deletion O(log n) on a balanced BST.
Real-world analogy: A company org chart is a tree. The CEO is the root. Each manager is an internal node. Individual contributors are leaves. Searching for a person means traversing down the hierarchy.
The 8 questions companies ask:
1. Binary Tree Level Order Traversal (BFS) — Use a queue. O(n) time, O(n) space. Amazon India uses this to distinguish BFS from DFS understanding.
2. Maximum Depth of Binary Tree — DFS with recursion. O(n) time. Every company asks this as a warm-up.
3. Validate BST — Recursion with min/max range per node. O(n) time. The common mistake: comparing only with direct parent instead of full range. Google India specifically checks this mistake.
4. Lowest Common Ancestor (LCA) — For BST: use BST property to navigate left or right. For general binary tree: DFS with null-check returns. O(n) time. Amazon India asks LCA in nearly every tree round.
5. Binary Tree Right Side View — BFS, take last node at each level. O(n) time. Swiggy and PhonePe use this in their first technical screen.
6. Serialize and Deserialize a Binary Tree — BFS or preorder DFS with null markers. O(n) time and space. A senior-level question — Amazon India SDE-2 and above.
7. Kth Smallest Element in BST — In-order traversal (left-root-right) is sorted for a BST. Count to k. O(n) time. Microsoft India and Walmart Labs ask this specifically.
8. Diameter of Binary Tree — For each node, longest path = left height + right height. Track global max. O(n) time. Meesho and Razorpay have both asked this.
Graph Questions — The 6 Most Asked
What it is: A graph is a collection of nodes (vertices) connected by edges. Graphs can be directed or undirected, weighted or unweighted, cyclic or acyclic. The two primary traversal algorithms are BFS (Breadth-First Search, uses a queue) and DFS (Depth-First Search, uses recursion or an explicit stack). Graph problems test your ability to model real-world relationships — social networks, delivery routes, dependency resolution — and traverse them correctly.
Real-world analogy: Google Maps is a weighted directed graph. Every intersection is a node, every road is an edge with a weight (distance or time). Dijkstra's algorithm finds the shortest path.
The 6 questions companies ask:
1. Number of Islands — DFS or BFS to mark connected land cells as visited. O(m × n) time. Amazon India and Google India both use this as an entry-level graph question.
2. Clone a Graph — DFS with a HashMap to avoid revisiting. O(n) time. LeetCode 133. Flipkart uses this.
3. Course Schedule (Topological Sort) — Detect cycle in a directed graph using DFS or Kahn's algorithm. O(V + E) time. Google India uses this for dependency resolution questions.
4. Shortest Path in Binary Matrix (BFS) — BFS guarantees shortest path in unweighted graphs. O(n²) time for n×n grid. Microsoft India and Goldman Sachs ask this.
5. Word Ladder — BFS with character-by-character substitution. O(n × l²) where l is word length. Amazon India's loop includes this at SDE-2.
6. Detect Cycle in a Directed Graph — DFS with a recursion stack (colour-state approach). O(V + E). For undirected graphs, use Union-Find instead. Read more on how Union-Find unlocks graph problems in product interviews and also explore the full guide on graph algorithms for MAANG interviews.
Nuance to know: BFS guarantees shortest path only in unweighted graphs. For weighted graphs, you need Dijkstra's algorithm (O((V + E) log V) with a min-heap). Engineers who conflate these two in Amazon interviews consistently receive negative feedback on problem modelling.
Key takeaway: Graph problems in Indian product company interviews test three things — traversal (BFS/DFS), cycle detection, and shortest path. If you master these three, you cover 80% of what Flipkart, Amazon India, and Google India actually ask at the SDE-1 to SDE-2 band.
Heap and Priority Queue Questions — The 5 Most Asked
What it is: A heap is a complete binary tree that satisfies the heap property: in a max-heap, every parent is larger than its children; in a min-heap, every parent is smaller. Python's `heapq` module implements a min-heap. Java's `PriorityQueue` defaults to a min-heap. The heap data structure enables O(log n) insertion and deletion, and O(1) access to the minimum or maximum element.
Real-world analogy: A hospital emergency queue. The patient with the most critical condition is always treated first, regardless of arrival order. That's a max-heap ordered by severity.
The 5 questions companies ask:
1. Kth Largest Element in an Array — Maintain a min-heap of size k. Process all elements. The top of the heap is your answer. O(n log k) time, O(k) space. Amazon India asks this at almost every SDE-1 screening.
2. Top K Frequent Elements — Use a HashMap for frequencies, then a min-heap of size k. O(n log k). Google India uses this to test heap intuition at SDE-2.
3. Merge K Sorted Lists — Use a min-heap to always extract the smallest head across k lists. O(n log k) time. This is a FAANG-standard question — Amazon India, Google India, and Microsoft India all use it.
4. Find Median from Data Stream — Two heaps: a max-heap for the lower half, a min-heap for the upper half. Keep sizes balanced. O(log n) per insertion, O(1) median. Swiggy and PhonePe have asked this at the SDE-2 to SDE-3 band.
5. Task Scheduler — Use a max-heap of task frequencies, simulate cooldown with a queue. O(n log n). Amazon India uses this to test both heap mechanics and greedy reasoning simultaneously.
This is the section where structured practice pays off most. Heap problems require you to think about two data structures at once — the heap and often a HashMap or deque alongside it. Engineers who practise these with a FAANG mentor develop the pattern-matching reflex that makes these questions solvable within 20 minutes, not 45.
In 2026, heap questions appear frequently in AI platform interviews too. Systems that schedule ML jobs, manage GPU queue allocation, or serve real-time model inference all model priority as heap operations. Knowing the theoretical complexity is not enough — being able to implement from scratch in Java or Python, under interview pressure, is what separates candidates at companies like Google DeepMind India and Microsoft Azure.
HashMap and Hashing Questions — The 6 Most Asked
What it is: A HashMap (also called a hash table or dictionary) maps keys to values using a hash function that converts a key into an array index. In the best case, get and put operations are O(1) average time. Collisions — when two keys hash to the same index — are handled by chaining (linked lists at each index) or open addressing. Java's `HashMap` uses chaining. Python's `dict` uses open addressing with pseudorandom probing.
Real-world analogy: A dictionary. You don't read every page to find a word — you go directly to the letter, then the word. The letter is your hash, the word is your key, the definition is your value.
The 6 questions companies ask:
1. Two Sum (HashMap variant) — For each element, check if `target - element` is in the map. O(n) time, O(n) space. Already covered in arrays, but the HashMap version is the expected answer in interviews.
2. Subarray Sum Equals K — Use a prefix sum HashMap. For each index, check if `prefixSum - k` exists in the map. O(n) time. Google India and Amazon India both use this at SDE-1 level.
3. Longest Consecutive Sequence — Insert all elements in a HashSet. For each element that starts a sequence (no element - 1 exists), count forward. O(n) time. This is a counter-intuitive O(n) solution — the naive O(n log n) sort-based approach is penalised at senior levels.
4. Group Anagrams — Sort each string as a canonical key. Group in a HashMap. O(n × k log k) where k is string length. See the complete string interview questions guide for related patterns.
5. First Non-Repeating Character — LinkedHashMap preserves insertion order. Iterate once for counts, once for first count-1. O(n). Microsoft India asks this as a HashMap fluency check.
6. Design HashMap from Scratch — Implement `get`, `put`, `remove` using arrays and linked list chains for collision handling. O(1) average. Amazon India's system design-adjacent coding rounds have included this. Understanding load factor and resizing is the differentiator.
Key takeaway: The HashMap is the single most versatile tool in a DSA interview. If you're stuck on a problem and you need to reduce O(n²) to O(n), the answer is almost always a HashMap. Developing this reflex — "can I trade space for time using a map?" — is the mark of an interview-ready engineer.
How the DSA & System Design with AI Program Can Help You
If you've been trying to prepare on weekends while handling sprint deliveries Monday through Friday, you already know the core problem: there's no one to tell you whether your approach was actually correct, just the Leetcode judge that tells you it passed. That feedback loop is too slow and too shallow for interview preparation.
The FutureJobs DSA & System Design with AI Program is built specifically for working engineers at service companies who need structured preparation without quitting their jobs. The program runs on evenings and weekends — 15–20 hours a week over 5 months. You work through 240+ hours of live classes covering DSA patterns, High-Level Design, Low-Level Design, and Prompt Engineering for AI-first roles.
The structure that matters most: you get a 1:1 FAANG mentor throughout the program — someone who has made the exact service-to-product transition you're planning, who can review your approach on a medium LeetCode problem and tell you in 10 minutes what a real Amazon interviewer would think. That is the feedback loop you don't get from GeeksForGeeks or InterviewBit alone.
On the financial question — because ₹3.5 lakh is real money and you're right to think carefully about it — the program uses a Pay-After-Placement model. You pay effectively ₹5,000 upfront and ₹4,999/month in EMI during the program. The remaining balance is paid 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.
Engineers who transition from service companies like TCS or Infosys to product companies report median salary increases of 60–80%, moving from ₹7–9 LPA to ₹14–18 LPA at the first product company, based on placement outcomes tracked across 2024–2025. With 700+ engineers enrolled this month in the DSA program, the cohort itself becomes part of your preparation network.
The AI-Era Question: Does DSA Still Matter in 2026?
In 2026, some engineers reasonably ask whether DSA matters when GitHub Copilot can generate a merge sort implementation in 3 seconds. The answer is yes — and more than before, for a specific reason. Product companies like Amazon India, Google India, and Flipkart are not testing whether you can write a binary search from memory. They are testing whether you can reason about constraints, choose the right data structure when multiple options exist, and communicate your trade-offs clearly. GitHub Copilot cannot do that reasoning for you in an interview room.
Post-2024 tech hiring normalisation, product companies in India have raised their DSA screening bar. LeetCode easy problems no longer clear first rounds at Swiggy or Meesho. The current bar for SDE-1 at a top product company in India is comfortable fluency with mediums across arrays, trees, graphs, and dynamic programming. For SDE-2, heap and graph problems with system design integration are expected.
The engineers who will thrive in 2026–2027 are not those who avoided DSA because Copilot exists — they're the ones who used AI tools to accelerate their learning and arrived at interviews able to think out loud at a whiteboard. That skill is not replaceable. For a structured approach to building it with limited time, see how to study DSA with only 1 hour a day.
Only 8 Seats Left — Cohort 3
Frequently Asked Questions
What data structures are tested most in product company interviews in India?
Arrays, HashMaps, Trees, and Graphs are the four data structures that appear in the highest volume of product company interviews in India. Among these, arrays — with sliding window, two-pointer, and prefix sum patterns — appear in virtually every first technical round at Amazon India, Google India, Microsoft India, Flipkart, and Swiggy. HashMaps are the most frequently used supporting structure. At the SDE-2 and above level, Heaps and Graph problems increase significantly.
What is the difference between data structures and algorithms in an interview context?
A data structure is how you organise data — an array, a HashMap, a heap, a tree. An algorithm is the procedure you apply to that structure — binary search, BFS, Kadane's algorithm, Dijkstra's. In interviews, the question always names a problem, and your job is to choose the right data structure first, then apply the right algorithm. Most interview failures happen at the data structure selection step, not the algorithm implementation step. Choosing a HashMap over a brute-force nested loop is the skill that interviewers are evaluating.
Which programming language should I use for DSA interviews in India in 2025?
Use the language you think fastest in. For most Indian backend engineers, that means Java or Python. Java's `PriorityQueue`, `HashMap`, `ArrayDeque`, and `TreeMap` map directly to interview data structures. Python's `heapq`, `defaultdict`, and `collections.deque` cover the same ground with less boilerplate. Both are accepted at Amazon India, Google India, and every major product company in India. If your current role is Java-heavy — as it is for most TCS and Infosys engineers — stay in Java. Switching languages adds cognitive overhead you don't need.
How long does it take to learn all data structures for a product company interview in India?
A working engineer practising 1–2 hours daily on weekdays and 3–4 hours on weekends can cover the core data structures — Arrays, Strings, Linked Lists, Stacks, Queues, Trees, Graphs, Heaps, and HashMaps — in approximately 3–4 months. Reaching comfortable interview fluency, where you can solve medium LeetCode problems within 25–30 minutes and explain your reasoning clearly, typically requires 5–6 months of structured practice. Unstructured practice — random LeetCode without pattern focus — can take 12–18 months to reach the same level, if at all.
Can I prepare for MAANG interviews while working full-time at a service company in Hyderabad?
Yes, and most successful transitions from TCS, Infosys, or Wipro to Amazon India, Flipkart, or Swiggy happen this way. The non-negotiable is structure. Engineers who prepare with a clear pattern-based curriculum — sliding window, two pointers, BFS/DFS, dynamic programming, heap patterns — and who have someone reviewing their approach regularly, consistently outperform engineers who grind random problems. 15–20 hours per week across evenings and weekends is sufficient for a 5-month preparation cycle. The geography is irrelevant — every major product company interview in India now runs remotely for the first two or three rounds. To understand why many service engineers struggle specifically, read why service engineers fail MAANG DSA rounds.
What salary can I realistically expect after moving from TCS to a product company in India?
Based on placement data tracked across 2024–2025, engineers moving from TCS, Infosys, or Wipro (₹6–9 LPA band) to product companies in India typically receive first offers in the ₹14–20 LPA range for SDE-1 equivalent roles. In Bengaluru, first product company offers at the 3–5 year experience band frequently reach ₹18–24 LPA at companies like Swiggy, Razorpay, Meesho, and CRED. MAANG offers — Amazon India, Google India, Microsoft India — at SDE-2 level regularly land in the ₹28–45 LPA range including equity. The salary jump justifies the preparation investment by a significant margin.
Is the FutureJobs DSA program worth it if I've already tried LeetCode on my own and quit?
Quitting LeetCode after two weeks is not a discipline problem — it's a structure problem. Most engineers who quit LeetCode alone do so because there's no progression signal, no one validating their approach, and no curriculum telling them what to practise next. The FutureJobs DSA & System Design program gives you a 5-month curriculum, a 1:1 FAANG mentor who reviews your specific weak points, and a cohort of peers at the same stage. The Pay-After-Placement model means the financial risk is minimised — you pay ₹4,999/month during prep and the balance only after your offer letter arrives.
Final Thoughts
You already know how to write good code. The gap between where you are now and a product company offer at ₹18–20 LPA is not a skills gap — it is a preparation structure gap. You need to know which 8 data structure patterns product companies actually test, how to approach each one in under 30 minutes, and how to explain your reasoning out loud to an interviewer who is evaluating your thinking, not just your output.
This guide has given you the complete map: Arrays and Strings for first-round fluency, Linked Lists and Stacks for core mechanics, Trees and Graphs for the mid-level depth that SDE-2 roles demand, and Heaps and HashMaps for the advanced pattern fluency that separates shortlisted candidates from hired ones.
The next step is not to open LeetCode and start randomly. The next step is to take one data structure from this guide — start with Arrays — and deliberately practise the two-pointer and sliding window patterns until you can solve any medium variant in under 25 minutes. Then move to HashMaps. Then Trees. This is how the engineers in Hyderabad, Bengaluru, and Pune who made the jump to Swiggy, Razorpay, and Amazon India actually did it.
The 30-60-90 day DSA plan is a strong starting framework if you want a concrete timeline. And if you want to understand the complete service-to-product transition — not just DSA but system design, compensation negotiation, and interview strategy — read the 2026 service-to-product company switch playbook.
The preparation is real, the transition is achievable, and the salary on the other side is worth every weekend you put in.
