Amazon Interview Questions
- DSA
- LLD
- HLD
Q1: Convert Number to English Words
Description:
This problem focuses on converting an integer into its full English word representation. It tests string manipulation, recursion or modular decomposition, and logical grouping of digits (hundreds, thousands, millions, etc.). In your case, this was part of an Alexa-related round, meaning the output had to be grammatically accurate and ready for spoken output. The challenge is not only correctness but also handling large numbers efficiently with readable code and minimal space overhead.
Example:
Input: 11023579
Output: Eleven million twenty-three thousand five hundred seventy-nine
Q2: Optimizing Car Capacity Over Time (Sliding Window + Two Pointer)
Description:
This question combined sliding window and two-pointer techniques—common in real-world optimization scenarios. The problem likely revolved around managing or maximizing capacity (e.g., number of passengers or resources) over a time sequence. The core concept tests understanding of dynamic window adjustments based on conditions (like time or weight limits) while maintaining optimal performance. It challenges candidates to find balance between time complexity and space usage for streaming or continuous data.
Q3: Serialize and Deserialize a Binary Tree
This classic problem evaluates understanding of tree traversal, recursion, and data representation. The challenge lies in converting a binary tree into a storable format (serialization) and rebuilding the exact same tree structure (deserialization). It’s commonly used to test knowledge of BFS/DFS traversal patterns, edge-case handling for null nodes, and maintaining the integrity of the tree structure across conversions — essential in designing communication protocols or persistent data structures.
Example:
Input Tree:
1
/ \
2 3
/ \
4 5
Serialized: “1,2,#,#,3,4,#,#,5,#,#”
Deserialized: (Reconstructed same tree)
Q4: Find K Closest Values in a BST
This problem tests both algorithmic optimization and BST traversal logic. Given a Binary Search Tree, a target value, and an integer K, the task is to find K nodes whose values are closest to the given target. The main insight involves leveraging the sorted nature of in-order traversal while maintaining a sliding window or two stacks (predecessor and successor) to efficiently find the nearest elements. It checks the candidate’s understanding of tree properties, recursion, and time-space trade-offs.
Example:
Input:
BST = [4, 2, 5, 1, 3], Target = 3.714286, K = 2
Output: [4, 3]
Q5: Find Median from Data Stream
This problem evaluates a candidate’s ability to handle continuous data efficiently using heaps or balanced trees. The goal is to maintain a running median as numbers are streamed in. It’s a frequent real-world challenge in systems that deal with sensor data, stock prices, or any kind of real-time metrics. The optimal solution maintains two heaps — a max-heap for the lower half and a min-heap for the upper half — ensuring logarithmic time complexity for insertion and constant time retrieval of the median.
Example:
Input Stream: [1, 2, 3, 4, 5]
Running Medians: [1, 1.5, 2, 2.5, 3]
Q6: Task Scheduler (Variation)
This problem revolves around optimizing CPU task scheduling with cooling intervals. Given a list of tasks and a cooldown period n, the goal is to minimize the total intervals needed to complete all tasks while respecting cooldown constraints. It tests knowledge of greedy algorithms, heaps, and frequency counting. The variation likely involved modified constraints such as different cooldown handling or custom task dependencies, pushing the candidate to reason beyond the standard LeetCode problem.
Example:
Input: tasks = [“A”,”A”,”A”,”B”,”B”,”B”], n = 2
Output: 8
Explanation: One possible order is A B idle A B idle A B.
Q7: Remove All Adjacent Duplicates in String II (Variation)
This problem tests stack-based string manipulation and efficient deletion of consecutive duplicate characters. The original version removes groups of the same character appearing k times consecutively. Variations may include additional conditions such as case sensitivity, different deletion thresholds, or performing multiple passes. It checks for proficiency in stack operations, string reconstruction, and in-place optimization.
Example:
Input: s = “deeedbbcccbdaa”, k = 3
Output: “aa”
Explanation: Remove “eee” and “ccc” first, then “bbb”, leaving “aa”.
Q8: Sort Singly Linked List (and Variations)
This question focuses on sorting a singly linked list — testing linked list manipulation and divide-and-conquer concepts. The base version involves using merge sort to achieve O(n log n) time and O(1) space. Follow-up variations, such as sorting in ascending/descending order, sorting by the number of set bits, and sorting by zeros in binary representation, test algorithmic flexibility and bitwise understanding. It challenges candidates to modify comparator logic dynamically while preserving list structure.
Example:
Input: 4 -> 2 -> 1 -> 3
Output: 1 -> 2 -> 3 -> 4
Follow-up Example: Sort by number of set bits
Input: 2 -> 3 -> 4 (binary: 10, 11, 100)
Output: 4 -> 2 -> 3
Q9: Combination Sum (Variation)
This question tests recursion and backtracking to generate all unique combinations that sum to a target value. The variation likely involved additional constraints, such as limiting the number of times an element can be used or handling duplicates differently. Candidates must reason about pruning conditions, recursion depth, and complexity trade-offs. The interviewer expected both brute-force and optimized backtracking solutions, along with detailed complexity analysis and dry runs.
Example:
Input: candidates = [2,3,6,7], target = 7
Output: [[2,2,3],[7]]
Explanation: All unique combinations that sum to 7.
Q10: Merge K Sorted Lists
This problem is a classic test of heap (priority queue) and linked list manipulation skills. The goal is to merge k sorted linked lists into one sorted list efficiently. The naive approach involves merging lists one by one, resulting in high time complexity (O(kN)). The optimal solution leverages a min-heap (priority queue) to always extract the smallest current element across all lists in O(N log k) time, where N is the total number of nodes. This tests understanding of divide and conquer, heap operations, and linked list traversal — common patterns in large-scale data merging, stream processing, and real-time ranking systems.
Example:
Input:
lists = [[1,4,5],[1,3,4],[2,6]]
Output:
[1,1,2,3,4,4,5,6]
Explanation:
The linked lists are:
1 → 4 → 5
1 → 3 → 4
2 → 6
Merging them step by step using a min-heap results in:
1 → 1 → 2 → 3 → 4 → 4 → 5 → 6
Q11: Minimum Cost to Combine Elements (Variant of Minimum Cost to Connect Sticks)
This problem requires repeatedly selecting two smallest values from an array, adding them, and pushing the resulting sum back into the array. The cumulative cost of each addition must be minimized until only one element remains. This is a classic greedy problem where at every step, combining the smallest elements yields the optimal solution. The best approach uses a min-heap (priority queue) to efficiently pop the two smallest values and push the computed sum back. This pattern appears in tasks like optimal merge pattern, Huffman coding, and cost-efficient data aggregation where incremental merging has weight (cost).
Example:
Input: [1, 2, 2, 2, 3]
Steps:
Pick 1 + 2 = 3 → [2, 2, 2, 3, 3]
Pick 2 + 2 = 4 → [2, 3, 3, 4]
Pick 2 + 3 = 5 → [3, 4, 5]
Pick 3 + 4 = 7 → [5, 7]
Pick 5 + 7 = 12 → [12]
Total cost = 3 + 4 + 5 + 7 + 12 = 31
Given sample from prompt:
1 + 2 = 3
2 + 2 = 4
3 + 3 = 6
4 + 6 = 10
Total = 3 + 4 + 6 + 10 = 23
Output: 23
Q12: Sliding Window Maximum
This problem involves finding the maximum value in every contiguous subarray (or “window”) of size k in a given array. It’s a cornerstone of the sliding window technique combined with a deque (double-ended queue) to achieve linear time complexity. The deque efficiently maintains candidate maximum elements for the current window while discarding those that fall out of range or are smaller than the current element. The key skill tested here is optimizing from a naive O(n*k) approach to an optimal O(n) solution through careful data structure use.
Example:
Input: nums = [1,3,-1,-3,5,3,6,7], k = 3
Output: [3,3,5,5,6,7]
Explanation:
Sliding windows and their max values:
[1,3,-1] → 3, [3,-1,-3] → 3, [-1,-3,5] → 5, [5,3,6] → 6, [3,6,7] → 7
Q13: Find the Single Element in a Sorted Array
Given a sorted array where every element appears twice except for one unique element, the task is to find the index of that single element in logarithmic time. The optimal approach uses binary search to identify where the pairing breaks. Observing that elements before the single number follow the (even, odd) index pattern and those after it reverse the pattern helps locate the single element efficiently. This question tests understanding of search-space reduction, bitwise reasoning, and pattern-based indexing.
Example:
Input: nums = [1,1,2,3,3,4,4,8,8]
Output: 2
Explanation: Element 2 occurs once and its index is 2.
Q14: Course Schedule (Topological Sort)
This classic graph problem asks whether all courses can be completed given a list of prerequisite pairs. It is a direct application of topological sorting — a linear ordering of nodes in a directed acyclic graph (DAG). Using either Kahn’s algorithm (BFS) or DFS with cycle detection, the solution determines if the dependency graph contains a cycle. It evaluates your understanding of graph traversal, dependency resolution, and cycle detection, crucial for scheduling, build systems, and resource management tasks.
Example:
Input: numCourses = 2, prerequisites = [[1,0]]
Output: true
Explanation: You can finish course 0 before 1.
Input: numCourses = 2, prerequisites = [[1,0],[0,1]]
Output: false
Explanation: Cycle detected — cannot complete all courses.
Q15: Maximum Bitwise AND of a Subarray (with Limited Increments)
This problem challenges you to maximize the bitwise AND value of any subarray of size m after performing at most k increments (each increment adds 1 to any chosen array element). The task tests understanding of bit manipulation, greedy optimization, and sliding window techniques. The key insight is to identify which bits can be “activated” (set to 1) across at least m elements with minimal increments. For each bit position, you determine whether it’s possible to make all numbers in a window have that bit set using available k operations. This problem blends binary reasoning with windowed optimization, often requiring an iterative bit-check approach or binary search over potential answers.
Example 1:
Input:
n = 4
arr = [1, 4, 10, 2]
k = 8
m = 2
Process:
Increment the last element: 2 → 10
Now array = [1, 4, 10, 10]
Possible subarrays of size 2 and their ANDs:
- [1,4] → 0
- [4,10] → 0
- [10,10] → 10
Output: 10
Example 2:
Input:
n = 3
arr = [1, 1, 1]
k = 3
m = 3
Process:
Increment all three elements by 1 each → [2, 2, 2]
Subarray of size 3 has AND = 2
Output: 2
Q16: Priority Queue and Sliding Window Problems (Online Assessment)
In the online assessment, two medium-level DSA problems were presented. The first could be solved efficiently using a priority queue (min/max heap), though a sorting-based solution was also viable. It likely involved optimizing retrieval of minimum or maximum values dynamically — a common use case for heaps in scheduling or frequency problems. The second question was a sliding window problem, focusing on maintaining a running window of data to compute metrics like sums, counts, or maximums. This category of problem tests one’s ability to optimize O(n*k) brute force approaches to linear O(n) solutions using two pointers or deques.
Example :
Input: arr = [1,3,-1,-3,5,3,6,7], k = 3
Output: [3,3,5,5,6,7]
Explanation:
Maintaining a window of size 3, record the maximum in each window using a deque or priority queue.
Q17: Maximum Sum BST in Binary Tree
This problem is a mix of tree traversal, recursion, and dynamic programming on trees. The task is to find the maximum possible sum of all keys of any subtree that forms a Binary Search Tree (BST). It involves checking each subtree for BST validity and simultaneously tracking the maximum sum. The challenge lies in managing the return of multiple values from recursion — minimum, maximum, and current sum — to validate and aggregate results efficiently. Time complexity is O(n) since each node is processed once.
Example:
Input:
1
/ \
4 3
/ \ / \
2 4 2 5
Output: 20
Explanation:
The subtree rooted at node 3 forms a valid BST with nodes [2, 3, 5], whose sum is 10, and another valid subtree rooted at 4 has sum 14. The overall maximum sum BST gives the result.
Q18: Array Transformation (String-based Logic)
The second problem from the technical round involved manipulating an array using string-based logic. It was an array question masked with string operations — a common pattern in interview questions meant to test parsing, mapping, or counting logic. The goal was to demonstrate reasoning and optimization skills, starting with a brute-force approach and later discussing an optimal O(n) solution. Even though coding was not completed due to time constraints, the candidate demonstrated strong analytical understanding and explained the optimization clearly.
Example :
Input: “1,2,3,2,1” → Transform based on given conditions (like grouping, mapping, or reduction).
Output: Result after transformation — depends on constraints.
Q19: Variation of Knapsack Problem
This problem is derived from the classic 0/1 Knapsack dynamic programming pattern, where you must maximize the total value of items placed in a knapsack without exceeding a weight limit. Variations may include constraints such as fractional choices, multi-dimensional capacities, or dependencies between items. The question tests understanding of recursion, memoization, and tabulation techniques, along with the ability to adapt standard DP logic to modified conditions. The goal is to balance optimization and complexity awareness, often requiring O(n * W) time where n is the number of items and W the maximum capacity.
Example:
Input:
weights = [1, 3, 4, 5]
values = [1, 4, 5, 7]
capacity = 7
Output: 9
Explanation:
Select items with weights 3 and 4 for total value 4 + 5 = 9.
Q20: Top View of Binary Tree
The “Top View” problem requires printing all nodes visible when a binary tree is viewed from above. It tests understanding of level-order traversal (BFS) along with horizontal distance mapping. Each node is associated with a horizontal distance (HD) from the root — nodes with the same HD are at different depths, and the topmost node for each HD is selected. Using a queue and an ordered map (or dictionary), one can record and print the topmost nodes efficiently. Time complexity is O(n) where n is the number of nodes.
Example:
Input Tree:
1
/ \
2 3
\ / \
4 5 6
\
7
Output: 2 1 3 6
Explanation: Nodes visible from the top view are 2, 1, 3, and 6.
Q21: Right View of Binary Tree
This problem involves printing all nodes visible when a binary tree is viewed from the right side. It’s solved using level-order traversal (BFS) or DFS with depth tracking, ensuring that for each level, the last node encountered is printed. The key challenge lies in managing traversal order efficiently to ensure only rightmost nodes per level are included. The time complexity remains O(n) as every node is visited once.
Example:
Input Tree:
1
/ \
2 3
\ / \
5 6 7
Output: 1 3 7
Explanation: Nodes 1, 3, and 7 are visible from the right view.
Q22: Search a Word in M×N Grid (Backtracking)
This is a classic backtracking problem where the goal is to find if a given word exists in a 2D character grid. Each letter of the word must be constructed from sequentially adjacent cells, where adjacent cells are horizontally or vertically neighboring. The same cell cannot be reused within a single word path. The challenge tests recursion, pruning, and boundary condition handling. Efficient solutions rely on marking visited cells temporarily and backtracking once a path fails, ensuring an overall complexity of O(M*N*4^L), where L is the word length.
Example:
Input:
board = [
[‘A’,’B’,’C’,’E’],
[‘S’,’F’,’C’,’S’],
[‘A’,’D’,’E’,’E’]
]
word = “ABCCED”
Output: true
Explanation: The word “ABCCED” can be found starting from the top-left cell following adjacent cells.
Q23: Daily Temperatures
This problem tests understanding of monotonic stack patterns and efficient traversal. Given an array of daily temperatures, the goal is to find for each day how many days one must wait until a warmer temperature occurs. If none exists, return 0 for that day. The brute-force approach checks all future days for each temperature, giving O(n²) complexity. The optimized solution uses a monotonic decreasing stack, maintaining indices of unresolved temperatures — when a warmer temperature appears, it resolves all smaller previous temperatures in O(n) total time. Candidates are expected to explain both brute-force and optimized stack-based approaches, dry-run examples, and discuss time/space trade-offs.
Example:
Input: temperatures = [30, 60, 90]
Output: [1, 1, 0]
Explanation:
- Day 1 (30): warmer day at 60 → wait 1 day
- Day 2 (60): warmer day at 90 → wait 1 day
- Day 3 (90): no warmer day → wait 0 days
Q24: Gas Station Circuit Problem
This is a well-known greedy algorithm problem. You are given two arrays: gas (fuel gained at each station) and cost (fuel needed to travel to the next station). The goal is to find the starting gas station index from which you can complete one full circuit, or return -1 if impossible. The brute-force approach tries each station, resulting in O(n²) complexity, while the optimized greedy method achieves O(n) by tracking total fuel balance and current tank balance. If the tank becomes negative at station i, the next possible start is i+1. The algorithm relies on the mathematical insight that a valid route exists only if total gas ≥ total cost.
Example:
Input:
gas = [1, 2, 3, 4, 5]
cost = [3, 4, 5, 1, 2]
Output: 3
Explanation:
Starting at index 3 (gas = 4):
- Travel 3→4: tank = +3
- 4→0: tank = +6
- 0→1: tank = +4
- 1→2: tank = +2
- 2→3: tank = +0
- Complete circuit successfully, so index 3 is valid.
Q25: Amazon-Focused Problem Strategy
For Amazon’s coding interviews, candidates should prioritize core algorithmic problem types that frequently appear across its SDE rounds. The most critical topics include:
- Arrays & Strings: Two-pointer, sliding window, prefix-sum patterns.
- Trees & Graphs: BFS, DFS, Topological Sort, Union-Find, and shortest path algorithms (Dijkstra).
- Dynamic Programming (DP): Subset, Knapsack, and state-based optimization patterns (memoization/tabulation).
- Heaps & Priority Queues: Task scheduling, merging, frequency tracking.
- Stack & Monotonic structures: Next Greater Element, Histogram, Rainwater trapping, etc.
Binary Search Patterns: Search space partitioning and rotated arrays.
These cover 80–90% of Amazon’s recurring problem themes, often with real-world contextual twists.
Q26: Curated Sheet for Highest ROI
For Amazon SDE I interviews, the most ROI-efficient problem sets are:
- Blind 75 — best general-purpose foundation.
- Amazon Interview Tag on LeetCode — directly reflects past and recurring patterns.
- Striver’s SDE Sheet — offers structured progression by topic.
Following these ensures balanced coverage of arrays, graphs, heaps, and DP — Amazon’s most commonly tested categories.
Q27: Interleaving String (String Manipulation / Dynamic Programming)
This problem involves determining if a given string s3 can be formed by interleaving two other strings s1 and s2 while preserving the order of characters in both. The task tests the candidate’s ability to apply dynamic programming (DP) to overlapping subproblems, typically using a 2D DP table where each state (i, j) represents whether the prefix s1[0..i) and s2[0..j) can form s3[0..i+j). The optimal solution runs in O(n*m) time and O(n*m) space. This question evaluates DP reasoning, string manipulation, and edge case handling.
Example:
Input: s1 = “aabcc”, s2 = “dbbca”, s3 = “aadbbcbcac”
Output: true
Explanation: The string “aadbbcbcac” is a valid interleaving of “aabcc” and “dbbca”.
Q28: Sliding Window with Time-based Stream Deduplication
This problem focuses on efficiently maintaining a sliding time window over a stream of incoming elements, each associated with a timestamp. At any moment, elements older than k minutes must be removed, and duplicates within the current window should not be allowed. The challenge lies in designing a data structure that supports O(1) average insertion, deletion, and lookup — commonly achieved using a combination of Queue (for order) and HashSet (for fast existence checks). This is a hybrid of sliding window and deduplication logic used in streaming systems or rate limiters.
Example:
Input:
Stream = [(A, 1), (B, 2), (A, 5), (C, 7)], k = 3
Output:
A → true
B → true
A → false (A already exists in last 3 minutes)
C → true
Explanation: Element A is ignored the second time since it exists within the time window [2, 5].
Q29: Alien Dictionary (Topological Sorting)
This advanced problem requires inferring the order of characters in an alien language given a sorted list of words according to that language’s lexicographic order. The problem reduces to a graph construction and topological sort task: create a directed edge u → v when character u precedes v in the alien ordering. The solution uses BFS (Kahn’s Algorithm) or DFS for topological sorting to determine a valid order. It tests graph reasoning, dependency resolution, and cycle detection — critical in compiler dependency or scheduling systems.
Example:
Input: words = [“baa”, “abcd”, “abca”, “cab”, “cad”]
Output: “bdac”
Explanation: From lexical differences, we infer b→d, a→c, leading to order “bdac”.
Q30: Word Ladder II (All Shortest Transformation Sequences)
This question expands upon the classic Word Ladder problem by requiring all shortest transformation sequences from a start word to an end word, where each transformation changes one letter and must result in a valid word. The optimized solution employs Breadth-First Search (BFS) to ensure shortest paths, coupled with backtracking to reconstruct all transformation sequences. It tests graph traversal efficiency, path reconstruction, and BFS-DFS interplay.
Example:
Input: beginWord = “hit”, endWord = “cog”, wordList = [“hot”,”dot”,”dog”,”lot”,”log”,”cog”]
Output: [[“hit”,”hot”,”dot”,”dog”,”cog”], [“hit”,”hot”,”lot”,”log”,”cog”]]
Q31: Online Assessment — Debugging Round
A timed coding segment (70 mins) containing two DSA problems — typical OA format where one must debug/implement and reason about correctness and complexity. These are medium-level problems that test correctness under constraints and edge cases.
Q32: Longest Subarray with Unique Characters (Sliding Window / Two-pointer)
Find the longest contiguous subarray (substring) that contains all unique characters. The optimal solution uses a sliding-window + hash map (or index map) to expand/contract the window in O(n) time, tracking the last seen index of each character to avoid re-scanning. This tests window maintenance, boundary conditions, and complexity reasoning.
Example (conceptual):
input: “abcabcbb” → output: 3 (“abc”)
Q33: Word Ladder
Transform one word into another by changing one letter at a time, where each intermediate word must exist in the dictionary. The shortest transformation length (or path) is found using BFS on an implicit graph of word transformations. A typical follow-up is to produce all shortest sequences (Word Ladder II) using layered BFS + backtracking.
Example:
begin = “hit”, end = “cog”, wordList = [“hot”,”dot”,”dog”,”lot”,”log”,”cog”] → [“hit”,”hot”,”dot”,”dog”,”cog”]
Q34: Sliding-window Stream Deduplication (time-windowed uniqueness)
Maintain a sliding time window of the last k minutes for a data stream; on each arrival remove entries older than k and reject duplicates currently in the window. Implement with a queue (or deque) for chronological order + hashset for O(1) existence checks; remove expired items from both. This tests streaming data structures and amortized complexity.
Example (conceptual):
Stream [(A,1),(B,2),(A,5),(C,7)], k=3 → second A rejected because within window.
Q35: Topological Sort — Class-based Design + Exception Handling
Solve ordering of tasks (dependencies) using topological sort (Kahn’s/BFS or DFS). The interview required coding as part of a class-based design, including methods and exception handling (try/catch) for invalid graphs (cycles), emphasizing clean API and robustness. Tests ability to combine algorithmic logic with proper code structure and error management.
Q36: Alien Dictionary (Hard — Graph + Topological Sort)
Infer character order from a lexicographically-sorted alien dictionary by constructing precedence edges between character pairs and performing a topological sort while detecting cycles. Tests graph construction and cycle detection plus correctness under many corner cases.
Q37: Word Ladder II (All Shortest Transformation Sequences)
Find all shortest transformation sequences between two words. Use BFS to build levels and parent pointers, then backtrack to reconstruct all paths. Emphasis on BFS for shortest-path guarantee and careful memory management for generating multiple sequences.
Q38: Count Number of Uni-Valued Subtrees
This binary tree problem requires counting all subtrees in which every node has the same value. It tests recursive traversal and conditional aggregation. The idea is to post-order traverse the tree, and for each node, check if its left and right subtrees are uni-valued and match the current node’s value. The function returns whether the subtree rooted at a node is uni-valued, while maintaining a global count.
Time Complexity: O(n) — each node is visited once.
Example:
Input:
5
/ \
1 5
/ \
5 5
Output: 4
Explanation: Four uni-valued subtrees → the three leaf nodes and the right subtree (5-5-5)
Q39: Search in a Rotated Sorted Array
This problem combines binary search with array rotation handling. The goal is to find a target element in a rotated sorted array in O(log n) time. At each step, determine which half (left or right) is sorted, and decide whether to continue searching in that half. It tests boundary analysis and modular arithmetic reasoning.
Example:
Input: nums = [4,5,6,7,0,1,2], target = 0
Output: 4
Q40: Maximum Falling Path Sum (Variation)
A dynamic programming problem where each cell in a matrix represents a path cost. From each cell, you can move diagonally or straight down to the next row, and the goal is to find the path with the maximum sum from top to bottom. Variations may include obstacles, restricted moves, or wrap-around. It tests multidimensional DP reasoning and state transition clarity.
Example:
Input:
[[2,1,3],
[6,5,4],
[7,8,9]]
Output: 17
Explanation: Path 3→6→8 gives the maximum sum.
Q41: Rotten Oranges (Variation)
This is a graph BFS problem involving a grid where each cell can be fresh, rotten, or empty. Every minute, fresh oranges adjacent to rotten ones become rotten. Variations may include irregular spread or multi-level propagation. It tests queue-based BFS, multi-source initialization, and edge-case handling when not all oranges rot.
Example:
Input:
[[2,1,1],
[1,1,0],
[0,1,1]]
Output: 4
Q42: Nodes at K Distance in a Binary Tree
Find all nodes in a binary tree that are K distance away from a target node. The problem combines tree traversal and BFS/DFS. A common approach first builds parent pointers for each node and then performs BFS from the target node, exploring left, right, and parent links.
Time Complexity: O(n)
Example:
Input:
3
/ \
5 1
/ \ / \
6 2 0 8
/ \
7 4
Target = 5, K = 2
Output: [7,4,1]
Q43: Lowest Common Ancestor (LCA) in a Binary Tree
Given two nodes in a binary tree, find their lowest common ancestor — the deepest node that is an ancestor of both. The recursive solution returns the node itself if it matches one of the targets or bubbles up the found ancestors from left and right subtrees.
Time Complexity: O(n)
Example:
Input:
3
/ \
5 1
/ \ / \
6 2 0 8
p = 5, q = 1 → LCA = 3
Q44: Minimize Elements to Make X Zero (Pick from Start or End of Array)
Given an array and a number x, remove elements from either end so that the sum of removed elements equals x. Minimize the number of elements removed. The problem is equivalent to finding the longest subarray whose sum equals totalSum – x. It tests prefix-sum, hash map, and sliding window logic.
Example:
Input: nums = [1,1,4,2,3], x = 5
Output: 2
Explanation: Remove [2,3] (right) or [1,4] (mixed) to reach sum = 5.
Q45: Detect Cycle in a Graph
Detect whether a directed or undirected graph contains a cycle. Implemented using DFS with recursion stack (for directed graphs) or Union-Find (Disjoint Set) for undirected ones. It evaluates understanding of graph traversal, back-edge identification, and parent tracking.
Example:
Input:
Edges: [[0,1], [1,2], [2,0]]
Output: true
Q46: Max Consecutive Ones III (Sliding Window / Two-Pointer)
This problem tests the sliding-window technique for handling limited flips in a binary array. The goal is to find the length of the longest subarray consisting of 1’s after flipping at most k zeros. The brute-force approach checks all subarrays (O(n²)), but the optimal solution keeps a dynamic window with at most k zeros inside.
Maintain two pointers left and right, and expand the window while counting zeros. When the zero count exceeds k, move left forward until the window becomes valid again. The maximum window size seen during this process is the answer.
Time Complexity: O(n)
Space Complexity: O(1)
Example 1:
Input: nums = [1,1,1,0,0,0,1,1,1,1,0], k = 2
Output: 6
Explanation: Flip the bold zeros → [1,1,1,0,0,1,1,1,1,1,1]
Example 2:
Input: nums = [0,0,1,1,0,0,1,1,1,0,1,1,0,0,0,1,1,1,1], k = 3
Output: 10
Q47: Maximum Storage Efficiency (Binary Search on Answer)
We have n tasks, each divided into num_segments[i] segments, and m storage units.
Rules:
- Each storage unit must hold at least one segment.
- A storage unit can only store segments from a single task.
- Each segment must be placed somewhere.
We must maximize the minimum number of segments in any storage unit.
This is a binary-search-on-answer problem:
Assume a candidate efficiency x (segments per storage unit) and compute how many units are possible if every unit stores at least x segments → sum(num_segments[i] / x).
If the total units ≥ m, x is feasible → move right; otherwise move left.
Time Complexity: O(n log max(num_segments))
Space Complexity: O(1)
Example 1:
Input:
n = 3
num_segments = [7,10,5]
m = 4
Output: 5
Explanation:
Storage 1 → 7 (Task 1)
Storage 2 → 5 (Task 2)
Storage 3 → 5 (Task 2)
Storage 4 → 5 (Task 3)
Min = 5 → maximum possible.
Example 2:
Input:
n = 3
num_segments = [4,3,5]
m = 3
Output: 3
Explanation: Each task gets one storage unit → min(4,3,5)=3
Optimized Code Snippet:
public static int getMaximumStorageEfficiency(List<Integer> taskSegments, long storageUnits) {
int low = 1;
int high = 0;
for (int seg : taskSegments) high = Math.max(high, seg);
int result = 1;
while (low <= high) {
int mid = low + (high – low) / 2;
long totalUnits = 0;
for (int seg : taskSegments)
totalUnits += seg / mid;
if (totalUnits >= storageUnits) {
result = mid; // feasible → try higher
low = mid + 1;
} else {
high = mid – 1; // infeasible → lower threshold
}
}
return result;
}
Q48: LRU Cache (Least Recently Used Cache Implementation)
This is a classic design and algorithmic question testing understanding of data structures (HashMap + Doubly Linked List) and O(1) operations. The goal is to implement a cache that evicts the least recently used item when capacity is reached. The get() and put() operations must both run in constant time. This problem tests the candidate’s grasp of linked list manipulation, hash-based indexing, and order tracking — foundational for designing in-memory caching systems.
Time Complexity: O(1) for both operations.
Space Complexity: O(n) for storing cache entries.
Example:
Input:
LRUCache cache = new LRUCache(2);
cache.put(1, 1);
cache.put(2, 2);
cache.get(1); // returns 1
cache.put(3, 3); // evicts key 2
cache.get(2); // returns -1
cache.put(4, 4); // evicts key 1
cache.get(1); // returns -1
cache.get(3); // returns 3
cache.get(4); // returns 4
Q49: LCS Variant (Longest Common Subsequence)
A modified version of the Longest Common Subsequence problem, testing understanding of Dynamic Programming (DP). The goal is to identify patterns and optimize overlapping subproblems through memoization. Variations may involve constraints such as matching under conditions, subsequence with character cost, or skipping elements. This evaluates the ability to recognize DP patterns even when disguised and to reason through base and transition cases.
Time Complexity: O(n*m)
Space Complexity: O(n*m)
Example:
Input: text1 = “abcde”, text2 = “ace”
Output: 3 // “ace”
Q50: Cart Items Budget Optimization
Given a list of item prices and a budget, for every prefix of the list, determine the minimum number of items to remove so the total does not exceed the budget. The current item (at index i) cannot be removed. The optimal approach uses a max-heap to remove the highest-priced items when the total exceeds the budget, ensuring minimal removals while keeping the sub-cart within the limit. This problem blends prefix processing with greedy heap-based optimization, commonly seen in e-commerce or scheduling systems.
Time Complexity: O(n log n)
Space Complexity: O(n)
Example 1:
Input: n = 3, cart_items = [2,3,7], budget = 8
Output: [0,0,2]
Explanation:
Sub-cart 0: [2] → total 2 ≤ 8 → remove 0
Sub-cart 1: [2,3] → total 5 ≤ 8 → remove 0
Sub-cart 2: [2,3,7] → total 12 > 8 → remove 2 (2,3)
Example 2:
Input: n = 4, cart_items = [1,2,3,4], budget = 5
Output: [0,0,1,2]
Q51: Max Consecutive Ones III (Sliding Window / Two Pointer)
This problem requires finding the longest subarray of 1’s you can get by flipping at most k zeros in a binary array. It tests the sliding window pattern and dynamic constraint management. You expand the right pointer until more than k zeros are in the window, then shrink from the left until valid again. The maximum valid window length throughout the iteration is the result.
Time Complexity: O(n)
Space Complexity: O(1)
Example:
Input: nums = [1,1,1,0,0,0,1,1,1,1,0], k = 2
Output: 6
Explanation: [1,1,1,0,0,1,1,1,1,1,1]
Q52: Maximum Profit in Job Scheduling (DP + Binary Search)
You’re given jobs defined by startTime[i], endTime[i], and profit[i]. The goal is to pick non-overlapping jobs to maximize total profit. It’s solved using Dynamic Programming with Binary Search. Sort jobs by end time, and for each job, use binary search to find the last non-overlapping one. Build a DP array where dp[i] represents the max profit up to the ith job. This problem is a classic test of DP optimization with interval scheduling.
Time Complexity: O(n log n)
Space Complexity: O(n)
Example:
Input:
start = [1,2,3,3]
end = [3,4,5,6]
profit = [50,10,40,70]
Output: 120
Explanation: Jobs [1-3] and [3-6] selected for 50 + 70.
Q53: Task Scheduler (Greedy + Counting + Priority Queue)
Given an array of CPU tasks and a cooling interval n, find the minimum number of intervals required to execute all tasks with the condition that identical tasks are separated by at least n intervals. The optimal approach uses greedy counting or a max-heap, scheduling the most frequent tasks first. The idea is to minimize idle times by filling available slots efficiently.
Time Complexity: O(n)
Space Complexity: O(1) (26 letters max)
Example:
Input: tasks = [“A”,”A”,”A”,”B”,”B”,”B”], n = 2
Output: 8
Explanation: A -> B -> idle -> A -> B -> idle -> A -> B
Q54: Basic Calculator (Stack / Expression Evaluation)
Implement a calculator that evaluates a mathematical expression string containing +, –, parentheses, and spaces. The problem is solved using a stack to handle nested parentheses and maintaining a running total. Each time you encounter (, push the current result and sign onto the stack; on ), pop and combine. This tests expression parsing, stack manipulation, and precedence awareness.
Time Complexity: O(n)
Space Complexity: O(n)
Example:
Input: “(1+(4+5+2)-3)+(6+8)”
Output: 23
Q55: Reconstruct Itinerary (Graph + Hierholzer’s Algorithm)
You’re given airline tickets [from, to] and must reconstruct a valid itinerary starting at “JFK”, using all tickets exactly once, in lexical order if multiple exist. This is solved using DFS + Hierholzer’s algorithm (Eulerian path) with a priority queue for lexical sorting. It tests graph traversal and backtracking, commonly seen in route reconstruction and dependency resolution problems.
Time Complexity: O(E log E) (E = number of edges)
Space Complexity: O(E)
Example:
Input: [[“MUC”,”LHR”],[“JFK”,”MUC”],[“SFO”,”SJC”],[“LHR”,”SFO”]]
Output: [“JFK”,”MUC”,”LHR”,”SFO”,”SJC”]
Q56: Remove K Digits (Monotonic Stack / Greedy)
Given a numeric string and an integer k, remove k digits to form the smallest possible number. The optimal approach uses a monotonic increasing stack — pop digits from the stack while the current digit is smaller than the top (and removals remain). This ensures lexicographical minimality. Handle leading zeros and edge cases when all digits are removed.
Time Complexity: O(n)
Space Complexity: O(n)
Example:
Input: num = “1432219”, k = 3
Output: “1219”
Explanation: Removing 4, 3, and 2 gives the smallest number.
Q57: All O(One) Data Structure (HashMap + Doubly Linked List)
Design a data structure that supports increment, decrement, and retrieval of keys with max/min counts in O(1) time.
Use two HashMaps:
- keyCount → maps keys to counts.
- countBucket → maps counts to doubly-linked buckets of keys.
Maintain head and tail pointers for fast min/max access. Each increment or decrement moves the key between buckets.
Time Complexity: O(1) average per operation.
Example:
Input:
[“AllOne”,”inc”,”inc”,”getMaxKey”,”getMinKey”,”inc”,”getMaxKey”,”getMinKey”]
[[],[“hello”],[“hello”],[],[],[“leet”],[],[]]
Output:
[null,null,null,”hello”,”hello”,null,”hello”,”leet”]
Q58: Maximum Subarray Sum with One Deletion (DP)
Find the maximum subarray sum where you can delete at most one element. This is a Dynamic Programming problem that maintains two DP arrays:
- noDelete[i] = max sum subarray ending at i (no deletion).
- oneDelete[i] = max sum subarray ending at i with one deletion.
Transition: - noDelete[i] = max(arr[i], arr[i] + noDelete[i-1])
- oneDelete[i] = max(oneDelete[i-1] + arr[i], noDelete[i-1])
Answer = max of both arrays.
Time Complexity: O(n)
Space Complexity: O(n) (can be optimized to O(1)).
Example:
Input: arr = [1, -2, 0, 3]
Output: 4
Explanation: Drop -2 → [1, 0, 3] sum = 4
Q59: Remove Duplicate Letters (Stack / Lexicographical Ordering)
Remove duplicate letters so each character appears once and the result is lexicographically smallest. Use a monotonic stack with frequency counting. At each step, pop characters larger than the current one if they appear again later.
Time Complexity: O(n)
Space Complexity: O(26)
Example:
Input: s = “cbacdcbc”
Output: “acdb”
Q60: Row With Maximum Ones (Matrix Scan / Binary Search)
Given a binary matrix, return the index of the row with the maximum number of 1s and the count.
A simple approach is counting 1s in each row.
Optimized version for sorted rows uses binary search to find the first 1 in each row (O(m log n)).
Time Complexity: O(mn) or O(m log n)
Space Complexity: O(1)
Example:
Input: mat = [[0,0,0],[0,1,1]]
Output: [1,2]
Explanation: Row 1 has 2 ones, which is the maximum.
Q1. Design an LRU Cache (Least Recently Used Cache)
This question tests your ability to maintain a cache that automatically evicts the least recently used item when the capacity is full. The challenge lies in achieving O(1) time complexity for both get() and put() operations. You typically use a HashMap (for constant-time lookups) paired with a Doubly Linked List (to maintain usage order). The design must handle updates, eviction, and cache misses efficiently — simulating how systems like browsers or databases manage in-memory storage for performance.
Q2. Design an LFU (Least Frequently Used) Cache
The LFU cache enhances the LRU concept by evicting items based on usage frequency rather than recency. The key challenge is to track how many times each item is accessed and ensure both insertion and lookup remain near O(1). This usually involves a HashMap of frequency lists. It mimics caching logic in applications like CDNs and recommendation systems, where frequently accessed data must be retained intelligently based on user behavior.
Q3. Design a Browser History System
This problem involves simulating browser navigation with “back” and “forward” functionality. The design uses two stacks or linked lists to track navigation states. It tests your understanding of state management, undo/redo mechanics, and handling user transitions seamlessly — concepts used in web browsers, editors, and mobile navigation systems.
Q4. Design an Underground System to Track Trips
The goal is to log check-ins and check-outs of passengers and compute the average travel time between stations. This system needs real-time event tracking, hash maps for fast lookups, and accurate aggregation of trip durations. It teaches log processing, state persistence, and data aggregation, which are fundamental in systems like transport analytics or ride-hailing services.
Q5. Design a Phone Directory System
You need to allocate, release, and manage phone numbers efficiently while ensuring no duplicates. This introduces concepts like resource pooling, reusability, and state tracking. Such designs are critical in systems that manage finite resources — like IP address allocation in cloud services or license key management.
Q6. Design a Search Autocomplete System
The autocomplete system predicts possible searches based on the input prefix and usage frequency. It’s commonly implemented using Tries (prefix trees) with frequency counts or priority queues. It teaches optimization for real-time search suggestions, ranking logic, and how large-scale search engines like Google provide instant recommendations.
Q7. Design an Authentication Manager with Token Expiry
Here, you manage authentication tokens that expire after a set time. You’ll implement efficient expiry validation, token renewal, and automatic cleanup. This mirrors real-world authentication mechanisms like JWT, OAuth, and session management systems, focusing on security and time-based validity.
Q8. Design a Parking Lot Management System
You’ll model different vehicle types, parking slots, and levels. This problem tests object-oriented modeling (using inheritance for vehicles), slot allocation logic, and real-time availability updates. It’s a strong exercise in system extensibility, where design decisions affect scalability as the lot size or vehicle variety increases.
Q9. Design a File Filtering System
This question explores object-oriented design and class responsibility principles. The system must filter files based on file size and file extension. A good approach involves creating a base Filter interface and implementing concrete classes like SizeFilter and ExtensionFilter. The focus is on extensibility — allowing new filters without modifying existing code — following SOLID design principles (especially Open/Closed Principle). This question evaluates your ability to model real-world systems into modular, maintainable code components.
Q10. Design Parking Lot
Design a parking-lot system that supports multiple parking styles (e.g., multi-level garages, open lots, valet, compact/large vehicle sections) and flexible pricing models (hourly, flat, dynamic/demand-based, subscription/passes). At the low-level you should focus on object-oriented responsibilities and clear interfaces: entities such as ParkingSpot, Vehicle, Ticket, PaymentProcessor, EntryGate, ExitGate, and Sensor should be defined with single responsibilities; strategy or policy objects can encapsulate pricing and slot-allocation rules; a ParkingManager coordinates lookups and assignments. Important concerns at this level include concurrency control for simultaneous spot allocation, extensibility to add new pricing or spot types without modifying core classes (open/closed), and clean error handling for payments and missed exits.
Q11. Design a Notification Service
This problem focuses on designing an extensible and scalable notification system capable of supporting multiple clients, each having multiple subscribers with unique notification strategies for varying urgency levels (High, Medium, Low). The service must store and retrieve customized strategies such as which channels (phone, email, SMS, etc.) to use per severity level. It tests understanding of OOP design principles, database schema modeling, and extensibility. A good design includes classes like NotificationService, Client, Subscriber, NotificationChannel, and NotificationStrategy. Each strategy maps severity levels to endpoints dynamically.
Database schema should capture relationships:
- Clients(client_id, name)
- Subscribers(subscriber_id, name)
- Notification_Strategies(client_id, subscriber_id, severity_level, channels[])
The candidate should also discuss how to support future expansion (e.g., adding new severity levels or channels like WhatsApp or push notifications) with minimal code change, ideally following the Open/Closed principle.
Q12. Linux Debugging / System Hang Diagnosis
Walkthrough of pragmatic debugging steps: df -h to check disk space, investigating mountpoints, logs, process lists, and follow-up remediation (cleanups, process kills, log rotation). Tests operational debugging and ability to drive to root cause under time pressure.
Q13. Design a Restaurant Reservation System
Design APIs and entities for managing restaurant reservations, including customers, tables, and booking times. Key entities include Customer, Table, Reservation, and Restaurant. The system should handle conflicts (overlapping bookings), provide availability lookup, and support modifications or cancellations. APIs may include:
- POST /reservations
- GET /restaurants/{id}/availability
- DELETE /reservations/{id}
The focus is on relationships (1-to-many between restaurants and tables) and ensuring thread-safe reservation creation under concurrent access.
Q14. Bus Ticket Booking System
Design a Bus Ticket Booking System with requirements including service modularization, concurrency control, and data management.
Key components include:
- Entities: Bus, Route, Seat, Booking, and User
- Services: BusService, RouteService, BookingService, PaymentService
- Concurrency: Handle simultaneous seat reservations using locks or optimistic concurrency.
- Database Schema: Normalize data for routes, buses, and reservations.
- API Design:
- POST /bookings – Book a ticket
- GET /buses?route=R1 – Get buses for a route
- DELETE /bookings/{id} – Cancel booking
The interviewer expected microservice-level modularity and DB schema reasoning rather than class diagrams — emphasizing adaptability and architectural thinking.
Q15. Design a Meeting Room Booking System
The challenge is to schedule meetings across rooms without overlapping bookings. This involves interval overlap detection, efficient searching, and sorting by time. It helps you learn about interval trees and conflict management, simulating real-world calendar apps like Google Calendar or Outlook.
Q16. Design a Hotel Management System
You’ll model entities such as rooms, guests, staff, and bookings. The design must handle room availability, check-in/check-out, and billing workflows. This teaches how to design relational schemas, business workflows, and data consistency rules vital for hospitality management software.
Q17. Design a Collaborative Document Editor (like Google Docs)
This complex problem involves multiple users editing the same document simultaneously. You’ll explore concepts like operational transforms, conflict resolution, and real-time synchronization. It’s a deep dive into concurrent systems, version control, and distributed state consistency — core ideas behind Google Docs or Notion.
Q18. Design a Cab Booking System (like Uber)
You’ll model drivers, riders, and trips, handling real-time location matching, pricing, and ride tracking. It’s a classic system combining geospatial queries, event streaming, and load balancing. You’ll learn how to handle real-time data, concurrency, and scalability similar to Uber, Lyft, or Ola platforms.
Q19. Design an Online Shopping Cart System
This problem centers around item management, inventory updates, and order checkout. It introduces transactional consistency between cart state and database records. The system models user sessions, price recalculations, and stock synchronization, which are the heart of every e-commerce platform.
Q20. Design a Social Media Feed System
This is about aggregating posts from followed users and ranking them. The design explores fan-out architecture, caching, and feed ranking algorithms. It demonstrates how Facebook, Instagram, or LinkedIn handle real-time personalization and large-scale content delivery.
Q21. Design an Inventory Management System
You’ll manage stock levels, suppliers, reordering, and alerts for low stock. This design requires transactional updates and consistency mechanisms. It’s vital for logistics and e-commerce, helping you understand supply chain automation and alert-driven workflows.
Q22. Design a Stack Overflow-like Q&A Platform
You’ll design components like users, questions, answers, votes, and reputation. The challenge is to handle relationships and ranking algorithms that determine visibility. This system teaches community moderation, reputation modeling, and social validation mechanisms — much like Stack Overflow or Quora.
Q23. Design a Distributed Cron System
A distributed cron ensures scheduled jobs run reliably across multiple servers. The system involves leader election, fault tolerance, and time synchronization. It mirrors real-world orchestration systems like Airflow, Kubernetes CronJobs, or Celery Beat — emphasizing resilience and consistency.
Q24. Design a Tic-Tac-Toe Game using OOP
A foundational design focusing on players, moves, board state, and win conditions. It highlights clean class structures (Board, Game, Player) and turn-based logic. Perfect for testing object interactions, input validation, and state transitions.
Q25. Design an Elevator System
You’ll design how elevators handle multiple requests, floors, and directions. The focus is on scheduling algorithms (SCAN, LOOK, FCFS), request queues, and multithreading. This teaches you how to optimize for minimal waiting time and fairness, simulating a real-world concurrent system.
Q26. Design a Movie Ticket Booking System
Here you’ll build logic for browsing, selecting, and reserving seats. It’s a concurrency-heavy problem focusing on race condition prevention, seat locking, and payment validation. Used to test database integrity and real-time availability like in BookMyShow or Fandango.
Q27. Design Splitwise or an Expense Sharing System
The challenge is to manage group expenses, calculate who owes whom, and simplify debts. It involves graph-based simplifications and balance tracking. This design emphasizes data accuracy, ledger management, and real-world financial modeling.
Q1. Parking System Design
This was part of your system design round, where you were asked to design a scalable Parking System. The task required defining both functional requirements (vehicle entry, exit, slot allocation, payment, etc.) and non-functional requirements (scalability, concurrency handling, database modeling). The focus was on how to structure a real-world system under constraints — balancing data consistency and performance. You discussed scalability, concurrency, and clear thought processes — indicating a solid understanding of distributed and modular architecture.
Q2. Design a Real-time Monitoring System
This design problem tests architectural thinking and scalability awareness. The goal is to design a system capable of tracking and displaying live metrics (e.g., CPU usage, service uptime, transaction counts) in real time. The design discussion should include event streaming (like Kafka), storage (like Time-Series Databases), and visualization (through dashboards). The interviewer likely evaluated trade-offs in latency, consistency, and fault tolerance — essential components of distributed system design.
Q3. Design Slack
Design a high-level architecture for a real-time chat/messaging platform like Slack that supports channels, direct messages, presence, message delivery guarantees, search, file attachments, and notifications. Focus on major components and trade-offs: real-time messaging via WebSockets or persistent connections, a pub/sub/message-broker layer for fan-out and horizontal scalability, durable storage for messages (time-series or document store) and metadata, separate services for user/profile management and presence, and a media store/CDN for attachments. Address QoS concerns (at-least-once vs exactly-once delivery trade-offs), partitioning strategy for channels/teams, indexing for search, and considerations for availability, latency, and rate-limiting. Also mention cross-cutting concerns like authentication/authorization (multi-tenant isolation), monitoring, and capacity planning.
Q4. Design a Booking System for an Adventure Park
This problem evaluates large-scale system design and scalability thinking. The system should support multiple adventure parks, each having multiple rides with 8 slots per ride. Users can book slots and receive a ticket with a unique TicketID after successful payment (payment logic is out of scope). With up to 1 million users per minute and 10,000 concurrent users, scalability, concurrency control, and consistency become core focus areas.
The discussion covers:
- Functional requirements: Slot booking, availability check, ticket generation.
- Non-functional requirements: High availability, low latency, fault tolerance.
- Architecture: A service-oriented design with components like User Service, Ride Service, Booking Service, Ticket Service, and DB Layer.
- Database design:
- Parks(park_id, name, location)
- Rides(ride_id, park_id, name, total_slots)
- Bookings(booking_id, user_id, ride_id, slot_time, status)
- Tickets(ticket_id, booking_id, issue_time)
- Parks(park_id, name, location)
Use distributed locking (like Redis) or atomic operations for concurrent slot booking. Sharding or partitioning strategies and caching (Redis or Memcached) improve performance.
The round assessed both conceptual clarity and practical scalability decisions.
Q5. Highly Concurrent Job Execution Orchestrator
Design a system that supports concurrent job execution with priority scheduling, license constraints, and auto-scalability under high traffic. Each job type has a license threshold — limiting how many jobs of that type can run concurrently.
The architecture should ensure:
- Queue management: Use priority queues for job ordering (e.g., Redis or Kafka-based job queue).
- License enforcement: Maintain distributed counters or tokens per job type to enforce thresholds.
- Autoscaling: Use metrics-based scaling (e.g., based on queue length or job latency).
- Resilience: Employ retry mechanisms, worker health checks, and stateless processing nodes for fault tolerance.
Databases should store job metadata, license counts, and execution states, while orchestration logic can run via a central controller service coordinating distributed worker nodes.
This tests concurrency handling, distributed coordination, and system scalability — core competencies for backend and SDE II+ levels.
Q6. Design Twitter
Create a simplified version of Twitter, focusing on posting tweets, following users, and generating personalized timelines. Discuss data modeling (User, Tweet, Follow), APIs, and scalability strategies (sharding by userId, caching timelines). Address fan-out vs fan-in for feed delivery, and queue-based architecture for scalable fan-out updates.
Q7. Design a Rider–Driver Matching System (Uber-like)
Architect a large-scale system for real-time driver–rider matching. The system should handle:
- Rider requests with pickup/drop coordinates
- Driver availability within radius
- Matching logic based on proximity, ETA, and surge pricing
- Real-time updates and fault tolerance
Design discussion should cover geospatial indexing (e.g., QuadTrees), caching, distributed messaging, and eventual consistency. Emphasis is on scalability, concurrency, and latency under high load.
Q8. Book Recommendation System
Design a large-scale Book Recommendation System (similar to Spotify or Netflix recommendations). The challenge involves combining content-based and collaborative filtering approaches
Key discussion points:
- Data Sources: user preferences, ratings, and metadata.
- Architecture: ingestion pipelines for user activity → feature extraction → model inference service → recommendation API.
- Storage: NoSQL for fast lookups, vector databases for similarity search, caching (Redis) for precomputed results.
- Scalability: microservices for user interaction, recommendation generation, and data indexing.
The focus is on explaining trade-offs between accuracy and latency and system scalability under high read traffic.
Q9. Design a Pastebin-like Service
A Pastebin clone stores and retrieves text snippets through short URLs. It tests knowledge of unique ID generation (hashing, base62 encoding), read-heavy optimization, and cache layers. This teaches data modeling, TTL policies, and content storage strategies for lightweight web apps.
Q10. Design an Amazon-like Job Portal
You’ll design for job listings, applications, filters, and recommendations. It involves search indexing, pagination, and user-job matching algorithms. It’s a large-scale design emphasizing database sharding, full-text search (Elasticsearch), and recommendation systems.
Q11. Design a Cloud Storage System (like AWS S3)
A large-scale design involving data sharding, replication, and consistency models. You’ll explore metadata management, chunked file storage, and replication policies to ensure durability. This system tests knowledge of distributed file systems like HDFS or GFS and global data access strategies.
Q12. Design a URL Shortener (like Bit.ly)
The goal is to generate and redirect short URLs reliably. It covers ID hashing, collision prevention, analytics tracking, and service scalability. You’ll learn about microservices, rate limiting, and read-heavy optimization for billions of requests per day.
Q13. Design a Scalable E-commerce Platform
You’ll build an end-to-end architecture for users, catalog, cart, orders, and payments. It involves microservices, asynchronous queues, and transaction-safe operations. A deep dive into high availability, data partitioning, and event-driven architectures used by Amazon and Flipkart.
Q14. Design a Scalable Messaging Platform (like WhatsApp)
This focuses on real-time messaging, user sessions, delivery acknowledgment, and storage. You’ll design WebSocket connections, message queues, and distributed delivery guarantees (at least once, exactly once). It teaches low-latency systems and real-time synchronization under massive concurrency.
Q15. Design a Concurrent Job Orchestrator
You’ll design a service that schedules and executes jobs based on priority and resource availability. It’s about task queues, worker pools, and autoscaling. This type of system powers CI/CD pipelines, ETL processes, and AI training orchestration.
Q16. Design a Real-Time News Feed System
This design focuses on feed aggregation, ranking, and real-time updates. It’s all about balancing fan-out on write vs. fan-out on read, cache layers, and data replication. It demonstrates how platforms like Facebook, Twitter, and LinkedIn keep millions of feeds fresh and relevant in milliseconds.