DSA / Arrays Interview Questions 2026
18 DSA / Arrays interview questions from Amazon, Microsoft, Flipkart, Swiggy, Zomato, Google, Meta, Netflix, Uber, Airbnb, Atlassian, TCS, PayU and more. Real questions from Technical, System Design, and HR rounds.
All DSA / Arrays Questions
Given a stock price array, find the maximum profit you can make with at most two buy-sell transactions. Discuss the DP state and how it generalizes to k transactions.
Given a list of delivery time windows for N restaurants, find the maximum number of restaurants whose windows overlap at any point in time. Explain the sweep-line approach, time complexity, and how this maps to capacity planning for Swiggy's logistics team.
Given a list of intervals, merge all overlapping intervals and return the result. Explain the sort-then-scan approach and the edge cases (touching intervals, single interval, all disjoint).
Given a list of bookings with start and end dates, find the minimum number of rooms needed so that no two overlapping bookings share a room. Explain the sweep-line and min-heap approaches.
Given a list of restaurant ratings and a minimum threshold, return the top-k restaurants sorted by rating using a min-heap. Explain why a heap beats a full sort for large k, and the time complexity of both approaches.
Given an array of transaction amounts, find all pairs whose sum equals a given target. Return the count of unique pairs. For example: [100, 200, 300, 400], target = 500 → pairs: (100,400), (200,300) → count: 2. What is the time and space complexity of your approach?
Find all pairs in an array that sum to a given target value. Explain the HashSet approach for O(n) time, handle duplicate pairs correctly, and discuss edge cases (negative numbers, empty array).
Given an array of integers and a target sum, return all unique triplets that sum to the target. Discuss time and space complexity. Then extend the problem to k-sum and analyze how recursion depth changes performance for large k.
Given an array of N integers, find the maximum product subarray. Explain why you need to track both the maximum and minimum product ending at each position, and handle zeros and negative numbers.
Given an array of integers, find the length of the longest subarray with a sum equal to zero. Explain the prefix sum + HashMap approach and why the naive O(n2) solution is unacceptable for large inputs.
Write a Java program to rotate a matrix 90 degrees clockwise in-place. Explain the transpose-then-reverse approach and why it is O(n2) time with O(1) extra space.
You have an array of daily payment failure counts for the past 30 days. Find the longest contiguous subarray where failures stayed below a given threshold k. Explain your sliding window approach and walk through the algorithm step by step.
Given a list of movie ratings (1-5 stars) for N users, compute the Pearson correlation between two users to measure taste similarity. Explain how this feeds into collaborative filtering.
Given a 2D matrix representing a payment heatmap (rows = hours, columns = days), find the submatrix with the maximum sum. The submatrix represents the peak payment activity window. Describe your approach — can you do better than O(n³)?
Given a matrix of 0s and 1s, find the largest rectangle containing only 1s and return its area. Walk through the histogram-based O(n*m) solution and discuss why the naive O(n2*m2) approach is unacceptable at scale.
Given a list of GPS coordinates representing a driver's path, compute the total distance travelled. Then find the longest contiguous segment where the driver was stationary (speed < 5 km/h). Discuss floating-point precision issues.
Given a list of Jira sprint start/end dates, find all sprints that overlap with a given date range. Implement an efficient solution using interval trees or sorted arrays with binary search.
Given delivery time estimates for N restaurants, find the restaurant with the minimum average delivery time across all its orders. Handle ties and explain your data structure choices.
Practice these questions with AI feedback
Get instant grading on your answers, identify your weak areas, and generate a personalised 14-day study plan — all free.
Build my study plan →