Software Engineering Interview Questions
1503+ curated interview questions covering system design, data structures & algorithms, and core computer science. Each question includes difficulty level, Bloom taxonomy level, and answer options.
Grouped by 64 high-demand topics
Practice All Questions Free →Arrays & Strings
Data Structures34 questionsWhat is the time complexity of accessing an element by index in an array?
Which operation has O(n) worst-case time when performed at the beginning of an array?
What is the space complexity of a prefix sum array for n elements?
What does nums.slice(1,3) return for nums = [10,20,30,40,50]?
Output of [1,2,3].map(x=>x*2).filter(x=>x>2) in JavaScript?
In a variable sliding window, what triggers moving the left pointer inward?
What is the time complexity of the sliding window solution to Longest Substring Without Repeating Characters?
Given nums = [-2,1,-3,4,-1,2,1,-5,4], what does Kadane's algorithm return?
Implement two-sum for an unsorted array returning indices. One solution guaranteed.
What is the amortized time complexity of Array.push() in JavaScript?
Why is string concatenation in a loop O(n²) in JavaScript?
What does Product of Array Except Self return for [1,2,3,4]?
What overlap condition must be true for intervals [a,b] and [c,d] (a<=c) to overlap?
After fixing nums[i] in 3Sum, what is the two-pointer time complexity for finding all pairs?
Time complexity of searching in an n×m matrix where rows and columns are sorted (LC 240)?
Why must you sort by start time before merging intervals?
Time complexity of Group Anagrams (LC 49) using sorted string as hash key?
Worst-case time complexity of naive string search?
Time complexity of finding longest common prefix among n strings each of length ≤m?
What is the optimal time complexity for solving the 'Arrays & Strings' classic problem?
Explain why initializing the prefix-sum map with {0:1} is necessary for 'Subarray Sum Equals K'.
After finding a valid window in Minimum Window Substring, why advance the left pointer?
Describe the two-step in-place algorithm to rotate a matrix 90 degrees clockwise.
What distinguishes the Maximum Product Subarray trick from Kadane's?
Which greedy choice minimizes intervals removed to make the rest non-overlapping (LC 435)?
How does length-prefix encoding in LC 271 handle strings containing the separator character?
What is the key insight enabling O(n) O(1)-space two-pointer solution to Trapping Rain Water?
Describe Boyer-Moore Majority Vote algorithm.
In Longest Repeating Character Replacement (LC 424), why keep maxFreq non-decreasing even when window shrinks?
Greedy approach for Jump Game II (LC 45) — minimum jumps to reach end?
How to find subarrays with sum divisible by k using prefix sums (LC 523)?
When would you choose a different approach for Arrays & Strings problems?
How does Z-algorithm help in string pattern matching?
Design an optimal solution for a real-world application of Arrays & Strings.
Dynamic Programming
Algorithms32 questionsWhat two properties must a problem have to be solvable with dynamic programming?
What is the time complexity of Longest Common Subsequence for strings of length m and n?
What is the recurrence relation for Coin Change (minimum coins) DP?
Explain the difference between memoization (top-down) and tabulation (bottom-up) DP.
What is dp[i][j] in the Edit Distance recurrence?
What is the base case for Edit Distance when one string is empty?
What does dp[i] represent in Word Break (LC 139)?
What is Unique Paths (LC 62) — how many paths from top-left to bottom-right in m×n grid?
What is the time complexity of Word Break (LC 139) with the DP approach?
Why does the naive recursive Fibonacci have O(2^n) time complexity?
What is the minimum number of coins needed to make amount=11 with coins=[1,5,6]?
What is the optimal substructure property and give an example.
What is the optimal time complexity for solving the 'Dynamic Programming' classic problem?
House Robber circular (LC 213): why do two linear passes work?
In 0/1 Knapsack with space optimization, why must you iterate weight in DESCENDING order?
Coin Change II (LC 518) counts combinations, not permutations. How does loop order enforce this?
In the stock problem state machine (LC 309 with cooldown), what are the three states?
Time complexity of Burst Balloons (LC 312)?
How does Delete and Earn (LC 740) reduce to the House Robber problem?
Why is Decode Ways (LC 91) a DP problem and what are the two choices at each digit?
Partition Equal Subset Sum (LC 416): what DP state do you use?
What is the space-optimized form of LCS that uses O(n) space?
How does the sliding window (rolling array) optimization reduce Edit Distance space from O(m*n) to O(n)?
Palindromic Substrings (LC 647): what is the DP approach and what does dp[i][j] represent?
What is 'interval DP' and when do you use it?
What is the state for Burst Balloons (LC 312) interval DP?
What is the O(n log n) algorithm for Longest Increasing Subsequence?
In Longest Increasing Subsequence O(n log n), what does tails[i] represent?
Target Sum (LC 494): how does it transform into subset sum with count?
In the stock problem Best Time to Buy and Sell Stock III (LC 123), what is the state?
When would you choose a different approach for Dynamic Programming problems?
Design an optimal solution for a real-world application of Dynamic Programming.
Trees & BST
Data Structures33 questionsWhat does inorder traversal of a BST produce?
What is the time complexity of search in a balanced BST?
What does the right side view of a binary tree (LC 199) return?
Why does comparing a node only to its direct parent fail when validating a BST?
In Lowest Common Ancestor of a Binary Tree (LC 236), when does the algorithm return the current root?
What is the time complexity of the O(n) balanced-tree check (LC 110) that returns -1 for unbalanced?
Implement maxDepth of a binary tree recursively.
What is the difference between tree height and tree depth?
What is the inorder successor of a node in a BST?
Time complexity of constructing a BST from a sorted array?
Why is iterative inorder traversal useful even though recursive is simpler?
Explain how to check if a binary tree is symmetric (LC 101).
What is the time complexity of LCA in a BST vs a general binary tree?
What is the time and space complexity of level-order traversal?
What is the space complexity of recursive DFS on a balanced binary tree?
What property makes AVL trees different from regular BSTs?
What is the difference between a complete binary tree and a perfect binary tree?
Solve Range Sum of BST (LC 938): count sum of values in range [low, high].
What is the time complexity of finding the kth smallest element in a BST?
What is the optimal time complexity for solving the 'Trees & BST' classic problem?
What are the three cases in BST node deletion?
How do you serialize a binary tree to uniquely reconstruct it?
How does the Diameter of Binary Tree (LC 543) differ from max depth?
Construct Binary Tree from Preorder and Inorder (LC 105): how do you find the left subtree size?
What is the time complexity of BST Iterator (LC 173) nextSmallest() and hasNext() operations?
In Binary Tree Maximum Path Sum (LC 124), what does the 'gain' function return vs what it records?
In Populating Next Right Pointers (LC 116), how do you connect nodes across different parent subtrees without extra space?
What is the key insight for Flatten Binary Tree to Linked List (LC 114) in O(1) space?
For Binary Tree Cameras (LC 968), what do the three states of each node represent?
How many unique BSTs can be formed with n distinct keys?
When would you choose a different approach for Trees & BST problems?
What is Morris traversal and what makes it special?
Design an optimal solution for a real-world application of Trees & BST.
Graphs
Algorithms33 questionsWhat is the time complexity of BFS on a graph with V vertices and E edges?
What is the difference between a directed and undirected graph?
What property of a graph must hold for topological sort to be possible?
What is the in-degree of a node in a directed graph?
What does an empty result from Kahn's topological sort indicate?
Time complexity of Dijkstra's algorithm with a binary min-heap?
Implement BFS to find shortest path length between source and destination in an unweighted graph.
How does multi-source BFS differ from single-source BFS?
Number of Islands (LC 200): what is the time and space complexity of the BFS approach?
Why must BFS (not DFS) be used to guarantee shortest path in unweighted graphs?
What makes a graph bipartite?
What is the time complexity of Floyd-Warshall all-pairs shortest path?
What is the space complexity of storing a graph as an adjacency matrix vs adjacency list?
How do you generate all 8 neighboring cells for a position (r,c) in a grid?
What is the time complexity of topological sort using Kahn's algorithm?
Why is the adjacency list preferred over adjacency matrix for most interview problems?
What is the optimal time complexity for solving the 'Graphs' classic problem?
Why does Dijkstra's algorithm fail with negative edge weights?
What optimizations make Union-Find nearly O(1) per operation?
In cycle detection for a directed graph using DFS, what do the three colors (0,1,2) represent?
Explain how to detect a redundant connection in an undirected graph using Union-Find.
Clone Graph (LC 133): why use a visited map from original node to cloned node?
What is the key difference between using DFS vs Union-Find for connected components?
How does the 'stale entry' check work in Dijkstra's priority queue implementation?
What is a strongly connected component (SCC) in a directed graph?
What does path compression do to the amortized complexity of Union-Find?
Minimum Cost to Connect All Points (LC 1584): which algorithm and why?
What is the Alien Dictionary (LC 269) approach?
Describe how to find all eventually safe nodes (LC 802) using topological sort.
Cheapest Flights Within K Stops (LC 787): why NOT use standard Dijkstra?
Accounts Merge (LC 721): how do you apply Union-Find to emails?
When would you choose a different approach for Graphs problems?
Design an optimal solution for a real-world application of Graphs.
Linked Lists
Data Structures33 questionsTime complexity of accessing the kth element of a singly linked list?
Time complexity of reversing a singly linked list?
Output of reversing [1,2,3,4,5]?
Time complexity of inserting a node immediately AFTER a given node (pointer already in hand)?
Space complexity of Floyd's cycle detection?
Why is a dummy head node useful when manipulating linked lists?
In Floyd's cycle detection, if slow moves 1 step and fast moves 2 steps, what does their meeting guarantee?
What three pointer variables are needed for iterative linked list reversal?
Implement iterative linked list reversal.
What does dummy.next return after Merge Two Sorted Lists?
Why does LRU Cache require a doubly linked list rather than singly?
Both naive (two-pass) and slow/fast (one-pass) approaches to find list middle are O(n). What is the practical advantage of slow/fast?
Time and space complexity of Odd Even Linked List (LC 328)?
Why must you save next=cur.next BEFORE setting cur.next=prev in iterative reversal?
Time complexity of deleting tail node in a singly linked list without a tail pointer?
What distinguishes sentinel nodes from regular nodes in a doubly linked list?
Correct order of three operations in Reorder List (LC 143)?
Time complexity of finding kth node from END of singly linked list in one pass?
What is the optimal time complexity for solving the 'Linked Lists' classic problem?
Time and space complexity of merging K sorted linked lists using a min-heap?
Space complexity of top-down recursive merge sort on a linked list?
How does the two-pointer technique find intersection of two linked lists (LC 160)?
In Reverse Nodes in k-Group (LC 25), how do you verify k nodes remain before reversing?
How to solve Add Two Numbers II (LC 445) without modifying input lists?
Why is merge sort preferred over quicksort for linked lists?
How does recursive reversal of a linked list work?
What happens during a cache HIT in LRU Cache (LC 146)?
What does Rotate List (LC 61) do and what is the efficient approach?
After detecting a cycle (slow and fast have met), why reset slow to head and advance both by 1 to find cycle entry?
What is the interleaving approach to Copy List with Random Pointer (LC 138)?
Describe approach to Flatten a Multilevel Doubly Linked List (LC 430).
When would you choose a different approach for Linked Lists problems?
Design an optimal solution for a real-world application of Linked Lists.
System Design Interview Framework
System Design20 questionsWhat does RADIO stand for in the system design interview framework?
In a 45-minute system design interview, how many minutes should you spend on the Infrastructure (architecture diagram) phase?
Which of the following is a NON-functional requirement?
What HTTP status code should a URL shortener return when redirecting a user from the short URL to the original URL?
What is the correct REST URL for retrieving all tweets posted by a specific user?
What is the polyglot persistence pattern?
Why should you always announce phase transitions during a system design interview?
You need to store 500 billion social graph edges with sub-millisecond multi-hop traversal queries. Which database do you choose?
What pagination type should you use for an infinite-scroll social feed and why?
A database primary server goes down. What is the standard recovery sequence?
What is the circuit breaker pattern used for?
When should you use gRPC instead of REST for service-to-service communication?
How do you handle a client submitting the same write request twice due to a network retry?
Which phase of RADIO is most commonly run short by candidates, and why does this hurt their score?
Why is it better to use cursor-based pagination than offset pagination for a social media timeline?
What is the correct order of concern when selecting a database in a system design interview?
A system has 100K read QPS and 5K write QPS on a single PostgreSQL instance. Which scaling action addresses the bottleneck?
What is the trade-off introduced by sharding a database by user_id?
A ride-sharing app needs to find all available drivers within 5 km of a rider's location in under 10ms. What is the most appropriate technology?
What is the Saga pattern used for in microservices?
Load Balancing
System Design20 questionsWhat does a load balancer primarily do?
Which load balancing algorithm always routes the same client IP to the same server?
L7 load balancers can route based on HTTP headers and URL paths.
AWS ALB (Application Load Balancer) operates at which OSI layer?
Explain the difference between active and passive health checks in load balancing.
A server has 100 active connections and another has 5. Which algorithm would route the next request to the less loaded server?
True or False: AWS ALB supports routing to Lambda functions as targets.
You have 3 servers: Server A (4 CPU), Server B (8 CPU), Server C (16 CPU). Which LB algorithm and weights would you configure?
Configure an Nginx upstream block that implements least-connections load balancing with server2 marked as backup.
Why does IP hash load balancing create problems when servers are behind NAT?
What is connection draining (deregistration delay) and why is it critical for deployments?
Compare the trade-offs between sticky sessions via IP hash vs cookie-based sticky sessions.
Your service has 4 backend servers. Server 1 goes down. With modulo hashing (client_id % 4), how many clients are remapped? With consistent hashing?
Analyze why least-connections is better than round-robin for long-polling API endpoints.
A load balancer with round-robin sends requests to 3 servers. Server 2 is slow (1000ms response) while servers 1 and 3 respond in 10ms. What happens to overall throughput?
Explain the 'power of two choices' load balancing strategy and why it outperforms random selection.
Design a highly available load balancer setup that eliminates the LB itself as a single point of failure.
Evaluate when you would choose AWS NLB over ALB for a production service.
Design a health check system for a load balancer that minimizes both false positives (removing healthy servers) and false negatives (keeping sick servers).
Design the load balancing architecture for a ride-sharing app like Uber handling 1 million RPS globally.
Caching
System Design20 questionsWhich caching pattern checks the cache first, then the database on miss, then populates the cache?
Write-through caching always writes to both cache and database simultaneously.
Which Redis data structure is best for implementing a real-time leaderboard?
What is a cache stampede?
Explain negative caching and when to use it.
Your Redis cache has 1GB memory limit. What eviction policy would you choose for a web session store where you want to keep recent sessions?
Design a cache key naming scheme for a multi-tenant SaaS application.
How does the Cache-Control header 's-maxage' differ from 'max-age'?
True or False: Redis is always faster than Memcached for caching.
What is the write-around caching pattern and when would you use it?
What is the difference between Redis Sentinel and Redis Cluster?
What is stale-while-revalidate and how does it improve user experience?
Compare LRU vs LFU eviction policies. When would LFU outperform LRU?
A popular article on your news site has 100,000 concurrent readers. Its cache entry expires. How do you prevent the cache stampede?
How would you implement cache warming after a Redis server restart?
A cache has 95% hit rate. A new feature doubles the number of cacheable objects. What happens to hit rate and how do you address it?
Design the caching strategy for a social media news feed where users see posts from accounts they follow.
Explain cache coherence problems in a multi-region deployment and how to address them.
How does Facebook's TAO system differ from a simple Redis cache?
Design a multi-layer cache for a global video streaming service.
Database Design
System Design21 questionsWhat does ACID stand for?
Which type of index is best for a query with a range condition like WHERE age BETWEEN 20 AND 30?
The left-prefix rule for composite indexes means a composite index on (a, b, c) can serve a query filtering only on column b.
What is denormalization and when is it appropriate?
True or False: A foreign key constraint automatically creates an index on the referencing column.
What is a covering index and how does it improve query performance?
How would you model a many-to-many relationship between Products and Tags?
Design a database schema for a Twitter-like system. What tables and indexes would you create?
Explain the N+1 query problem and how to fix it.
What is an index-only scan and when does it occur?
What is optimistic locking and when does it fail?
What is connection pooling and how do you size a connection pool?
A query using WHERE email = ? is slow despite an index on email. What could cause this?
What is the difference between REPEATABLE READ and SERIALIZABLE isolation levels?
When would you choose Cassandra over PostgreSQL?
How do you handle storing hierarchical/tree data in a relational database?
Design an audit trail system that records all changes to a users table.
Explain the CAP theorem as it relates to database selection.
A PostgreSQL table has 10 million rows. A query SELECT * FROM orders WHERE status = 'pending' runs a sequential scan despite an index on status. Why?
You need to add a NOT NULL column to a 500-million-row table in production. How do you do it without downtime?
Design a database schema for a multi-tenant SaaS CRM application.
Microservices Architecture
System Design20 questionsWhat is Conway's Law?
Microservices should always share a single database to maintain data consistency.
Which pattern allows migrating from monolith to microservices incrementally without big-bang rewrite?
What is a bounded context in Domain-Driven Design?
True or False: gRPC is always better than REST for microservice communication.
Design the service decomposition for a food delivery app like DoorDash.
What is the bulkhead pattern and how does it relate to microservices resilience?
Compare client-side vs server-side service discovery.
What problems does the microservices pattern introduce that a monolith doesn't have?
How does the API Gateway pattern relate to the BFF (Backend for Frontend) pattern?
What is the primary advantage of Microservices Architecture?
When should you NOT use Microservices Architecture?
What is the time complexity of the core operation in Microservices Architecture?
How does Microservices Architecture handle failures?
How do you handle data consistency across microservices that own separate databases?
What is the outbox pattern and why is it important?
What is a service mesh and when is it justified?
How would you implement distributed tracing across 5 microservices?
Design the microservices communication strategy for a real-time ride-matching service.
Design a microservices architecture that handles Black Friday traffic (100x normal load).
Sorting & Searching
Algorithms31 questionsWhat is the time complexity of binary search on a sorted array of n elements?
Which sorting algorithm is stable and guarantees O(n log n) worst case?
What is the space complexity of mergesort?
Why does quicksort degrade to O(n²) on already-sorted input with last-element pivot?
Implement binary search to find the leftmost occurrence of a target.
What is the time complexity of the 'binary search on answer' approach for Koko Eating Bananas (LC 875)?
When should you use counting sort instead of comparison-based sort?
What is the loop termination condition for binary search on answer and why?
Find First and Last Position (LC 34): what two binary searches do you run?
What is Dutch National Flag problem (LC 75) and what algorithm solves it?
What is the time complexity of Median of Two Sorted Arrays (LC 4)?
Why is heapsort in-place while mergesort requires O(n) extra space?
Count inversions in [3,1,2,4]: how many inversions are there?
What is the worst-case time and space complexity of quicksort?
What does stability in a sorting algorithm mean and why does it matter?
What is the optimal time complexity for solving the 'Sorting & Searching' classic problem?
In the Lomuto partition scheme, what loop invariant is maintained?
What makes binary search on rotated sorted array (LC 33) more complex than standard binary search?
Quickselect finds the kth largest element in O(n) average. Why is it not O(n log n)?
Search a 2D Matrix (LC 74) in O(log(m*n)): how do you treat it as a sorted 1D array?
What is the lower bound on the number of comparisons needed to sort n elements?
Implement the Lomuto partition function for quicksort.
What is Timsort (used in Python and modern JS) and what makes it adaptive?
What happens at the boundary when lo==hi in binary search on answer?
For what type of problems is binary search on answer NOT applicable?
How does binary search apply to finding the minimum in a rotated sorted array (LC 153)?
How does mergesort count inversions (pairs where i<j but arr[i]>arr[j])?
Aggressive Cows (classic problem): how does binary search on answer apply?
Split Array Largest Sum (LC 410): what is the feasibility check for binary search on answer?
When would you choose a different approach for Sorting & Searching problems?
Design an optimal solution for a real-world application of Sorting & Searching.
Stacks & Queues
Data Structures34 questionsWhat does LIFO stand for and which data structure follows this principle?
What is the time complexity of getMin() in a Min Stack using an auxiliary min-stack?
Why is array.shift() O(n) in JavaScript, and how can you avoid this for a queue?
In Valid Parentheses (LC 20), why pop and compare rather than just peek?
In Daily Temperatures (LC 739), why store indices rather than temperature values in the stack?
Time complexity of the monotonic stack approach to Next Greater Element?
What is the space complexity of BFS on a graph with V vertices and E edges?
Which expression evaluates correctly with RPN (Reverse Polish Notation): ['2','3','+','4','*']?
BFS vs DFS: which guarantees shortest path in an unweighted graph?
What is the space complexity of Largest Rectangle in Histogram (LC 84) using the monotonic stack?
What is the time complexity of Decode String (LC 394) and why?
Why does a stack naturally model DFS while a queue naturally models BFS?
Stack or Queue for implementing Undo/Redo in a text editor?
What does 'monotonic' mean in the context of a monotonic stack?
How many times is each element pushed and popped in the monotonic stack for Next Greater Element?
What is the worst-case time complexity of a single pop() operation in a two-stack queue?
What is the optimal time complexity for solving the 'Stacks & Queues' classic problem?
What is the amortized time complexity of dequeue in a two-stack queue?
What invariant does a monotonic decreasing stack maintain?
Implement a Min Stack with O(1) push, pop, top, and getMin.
Why must BFS mark nodes as visited BEFORE enqueuing rather than after dequeuing?
In Largest Rectangle in Histogram (LC 84), what does the sentinel 0 appended to heights array do?
What two stacks (or one stack of pairs) does Decode String (LC 394) use?
How does Rotting Oranges (LC 994) use multi-source BFS?
Car Fleet (LC 853): which pattern and why?
How do you represent state in Open the Lock (LC 752) BFS?
What is the time complexity of Word Ladder (LC 127) BFS?
What invariant does the deque maintain in Sliding Window Maximum (LC 239)?
What is the key insight for Basic Calculator (LC 224) handling parentheses?
Pacific Atlantic Water Flow (LC 417): why BFS from oceans rather than from cells?
Design a data structure supporting push, pop, top, and retrieveMax all in O(1).
Explain how to implement a stack using a single queue.
When would you choose a different approach for Stacks & Queues problems?
Design an optimal solution for a real-world application of Stacks & Queues.
Hash Tables
Data Structures32 questionsWhat is the average time complexity of inserting into a hash table?
What is the time complexity of checking if a string is an anagram of another using a frequency array?
What is the difference between a JS Map and a plain Object for use as a hash map?
In Two Sum (LC 1), what is stored as key and value in the hash map?
Why does grouping anagrams with a sorted-string key cost O(n*k*log k) while a frequency-count key costs O(n*k)?
What does a hash collision mean and how does separate chaining resolve it?
What is the time complexity of Top K Frequent Elements (LC 347) with bucket sort?
What is the load factor of a hash table and why does it matter?
What are the two main collision resolution strategies?
What is the time complexity of Time Based Key-Value Store (LC 981) get() operation?
How do you use a hash set to detect if a linked list has a cycle?
What hash key would you use to group strings that are 'scramble anagrams' (same chars in same or different order)?
What is the space complexity of Group Anagrams (LC 49) with n strings of length k?
What is the average time to find all subarrays with sum equals k using a hash map?
Why does validating an anagram with a fixed-size array (size 26) use O(1) space?
How does Isomorphic Strings (LC 205) differ from checking if strings are anagrams?
In Happy Number (LC 202), why can you use a set instead of Floyd's cycle detection?
What is the optimal time complexity for solving the 'Hash Tables' classic problem?
In Subarray Sum Equals K (LC 560), why initialize the map with {0:1}?
Longest Consecutive Sequence (LC 128): why check only from sequence STARTS?
In Word Pattern (LC 290), why do you need TWO maps?
How does Contiguous Array (LC 525) convert the equal-zeros-and-ones problem to a prefix sum problem?
Four Sum Count (LC 454): how does splitting into two two-sum problems reduce O(n⁴) to O(n²)?
What is open addressing with linear probing?
Repeated DNA Sequences (LC 187): find all 10-char sequences that appear more than once.
How does Insert Delete GetRandom O(1) (LC 380) achieve O(1) deletion from the middle of the value set?
What trick does First Missing Positive (LC 41) use to achieve O(n) time and O(1) space?
What is a perfect hash function?
When would you choose a different approach for Hash Tables problems?
Explain how Rabin-Karp rolling hash enables O(n) substring search.
LFU Cache (LC 460): what is different from LRU and what data structures does it use?
Design an optimal solution for a real-world application of Hash Tables.
Heaps & Priority Queues
Data Structures31 questionsIn a min-heap stored as an array, what is the parent index of the node at index i?
What is the time complexity of extracting the minimum from a min-heap?
What is the heap invariant for a min-heap?
What is the time complexity of peek() (see minimum without removing) in a min-heap?
Why use a min-heap of size k to find the kth LARGEST element?
What is the time complexity of building a heap from n elements (Floyd's heapify)?
What is the time complexity of merging K sorted lists of total N elements using a min-heap?
How do you simulate a max-heap using a min-heap in JavaScript?
What is the difference between a heap and a sorted array for priority queue operations?
In heapsort, after building the max-heap, what is the next step?
Why is the heap called a 'partially sorted' structure?
What is the time complexity of Reorganize String (LC 767)?
What is the time and space complexity of the two-heap MedianFinder?
What happens if you insert into a max-heap a value smaller than the root?
What is the optimal time complexity for solving the 'Heaps & Priority Queues' classic problem?
Explain the two-heap approach to Find Median from Data Stream.
Task Scheduler (LC 621): what determines the minimum intervals needed?
How does Connect Ropes for Minimum Cost work with a heap?
When would you prefer a sorted array over a heap as a priority queue?
Why is heapsort not stable?
What is the Kth Smallest Element in a Sorted Matrix (LC 378) approach using binary search vs heap?
Find K Pairs with Smallest Sums (LC 373): what initial entries go into the heap?
Furthest Building (LC 1642): what is the heap-based greedy strategy?
IPO (LC 502): why use two heaps — one for capital and one for profit?
Design Twitter (LC 355): how do you implement getNewsFeed efficiently with a heap?
Swim in Rising Water (LC 778): how is this a heap problem?
Explain why buildHeap (Floyd's algorithm) is O(n) rather than O(n log n).
When would you choose a different approach for Heaps & Priority Queues problems?
Sliding Window Median (LC 480): how do you handle element removal from the two heaps?
What is the advantage of a d-ary heap over a binary heap for Dijkstra's algorithm?
Design an optimal solution for a real-world application of Heaps & Priority Queues.
Recursion & Backtracking
Algorithms32 questionsWhat is the recursion base case for Combination Sum (LC 39)?
What does the 'un-choose' step in backtracking accomplish?
For Letter Combinations of Phone Number (LC 17) with input '23', how many combinations are there?
What is the key difference between permutations and combinations in backtracking?
In backtracking, why must you push `[...path]` instead of `path` to the result?
Time complexity of generating all permutations of n distinct elements?
What is the choose/explore/un-choose pattern in backtracking?
In Combination Sum (LC 39), why sort the candidates array first?
Implement the backtracking solution to generate all subsets of [1,2,3].
In Word Search (LC 79), why mark the cell with '#' instead of using a separate visited set?
Generate Parentheses (LC 22): what are the two pruning conditions?
What is the time complexity of generating all combinations C(n,k)?
N-Queens: how many solutions exist for n=4?
How does the start index in the combinations template prevent duplicate combinations?
What is the relationship between backtracking and DFS?
What is the time complexity of Word Search (LC 79)?
What are the three types of conflict in N-Queens (same row, column, diagonal)?
What is the optimal time complexity for solving the 'Recursion & Backtracking' classic problem?
In N-Queens, why does row-col uniquely identify a diagonal?
What is the time complexity of Sudoku Solver in the worst case?
How do you handle duplicate elements in Subsets II (LC 90)?
In the Combination Sum II (LC 40), how do you skip duplicates at the same recursion level?
What is the branching factor and depth of the recursion tree for Permutations(n)?
Palindrome Partitioning (LC 131): how do you efficiently check if a substring is a palindrome?
In Restore IP Addresses (LC 93), what constraints limit each segment?
Why is backtracking considered 'exhaustive' yet often practical?
Beautiful Arrangement (LC 526): what constraint is checked at each position?
Why does Permutations II (LC 47) skip nums[i] when nums[i]==nums[i-1] AND !used[i-1]?
How does the Trie improve Word Search II (LC 212) compared to running LC 79 for each word?
When would you choose a different approach for Recursion & Backtracking problems?
Expression Add Operators (LC 282): why track the 'previous operand' in the backtracking state?
Design an optimal solution for a real-world application of Recursion & Backtracking.
API Gateway
System Design21 questionsWhat is the primary purpose of an API Gateway?
API Gateways can perform SSL termination, meaning they decrypt HTTPS traffic and forward HTTP to backends.
Which of the following is NOT typically handled by an API Gateway?
What is the circuit breaker pattern in the context of an API Gateway?
Explain the difference between an API Gateway and a Load Balancer.
What HTTP status code should an API gateway return when the circuit is open?
What is the BFF (Backend for Frontend) pattern?
You have a mobile app and a web app consuming the same API. Mobile needs compact JSON responses, web needs full responses. Which pattern do you use?
Design the authentication flow for an API gateway handling JWT tokens with 100ms latency budget.
True or False: AWS HTTP API is always the better choice over REST API in AWS API Gateway.
How does distributed rate limiting work across 10 API gateway instances?
Compare URL path versioning vs header versioning for APIs. Which would you recommend and why?
A payment service is experiencing 30% error rate. How should the API gateway circuit breaker respond?
How do you handle WebSocket connections through an API Gateway?
Explain idempotency keys and how the API gateway can help implement them.
What is request collapsing (or request coalescing) at the API gateway level?
Evaluate the trade-offs of putting an API gateway vs using a service mesh (Istio) for cross-cutting concerns.
A developer reports that 10% of API requests are getting 401 errors even with valid tokens. How do you debug this at the gateway?
How would you implement request signing (like AWS Signature V4) at the API gateway?
Design an API gateway that handles 1 million requests per second with 99.99% availability.
Design an API versioning strategy for a public API used by 1000+ third-party developers.
Database Scaling
System Design21 questionsWhat is the primary purpose of a read replica in a database setup?
In master-slave replication, replicas can accept write operations.
Which sharding strategy ensures that adding a new shard requires moving minimal data?
What is replication lag and why does it matter?
What is the difference between vertical partitioning and horizontal partitioning (sharding)?
True or False: Adding more read replicas always improves write throughput.
What is the main problem with modulo-based hash sharding when you need to add a new shard?
Explain geographic sharding and how it helps with GDPR compliance.
How does PostgreSQL table partitioning differ from sharding?
Explain synchronous vs asynchronous replication. When would you use each?
What is CQRS and what problem does it solve?
What is the difference between a partition key and a sort key in DynamoDB?
A company has a users table with 200M rows. Queries by user_id are fast but queries by email are slow. What is the solution?
What are virtual nodes in consistent hashing and why are they needed?
What is a hot shard and how do you detect and fix it?
Why is a foreign key relationship across shards problematic?
Explain the CAP trade-off between PostgreSQL and Cassandra.
Design a sharding strategy for a social network where you need to efficiently fetch all posts by a user AND efficiently fetch a global feed of recent posts.
Design a strategy for migrating from 4 shards to 8 shards with zero downtime.
Design a strategy for handling the 'celebrity problem' in a sharded social network database.
Design the database scaling architecture for a ride-sharing app with 5M rides per day globally.
Message Queues
System Design20 questionsWhat is the primary advantage of using a message queue over direct synchronous API calls?
What is the difference between at-least-once and at-most-once delivery?
In Kafka, what determines which partition a message is sent to when using a key?
AWS SQS Standard Queue guarantees exactly-once delivery.
What is a Dead Letter Queue (DLQ)?
What is the visibility timeout in SQS and why is it important?
True or False: Kafka deletes messages after they are consumed by a consumer group.
Implement an idempotent Kafka consumer for processing payment events.
What is the difference between Kafka's consumer group and a traditional queue consumer?
A Kafka topic has 6 partitions. Consumer group A has 4 consumers. How are partitions distributed?
Compare Kafka and RabbitMQ. When would you choose each?
What is the saga pattern and how does it solve distributed transactions?
Explain event sourcing and its trade-offs.
A consumer is processing Kafka messages slowly, causing increasing lag. How do you address this?
Explain choreography vs orchestration in the saga pattern.
How does Kafka handle broker failures without losing messages?
How do you achieve message ordering across multiple Kafka partitions?
Design a real-time notification system for a food delivery app using message queues.
How would you implement exactly-once semantics in Kafka?
Design a system to process 10 million IoT sensor readings per second using message queues.
Distributed Systems Fundamentals
System Design21 questionsIn the CAP theorem, what does 'P' (Partition Tolerance) mean?
Raft requires a majority (quorum) of nodes to elect a leader.
Which databases are examples of CP systems?
What is eventual consistency?
True or False: Vector clocks can detect concurrent events, while Lamport timestamps cannot.
A distributed database processes a write. How many nodes must acknowledge before the client gets a success response?
For a 5-node distributed database, what R and W values guarantee strong consistency?
What is the two-generals problem?
How does consistent hashing relate to distributed systems consensus?
What happens to a Raft cluster when the leader node crashes?
Explain the split-brain problem and how Raft prevents it.
What is the difference between Lamport timestamps and vector clocks?
Explain the PACELC theorem and give an example of a PA/EL system.
What is hinted handoff in Cassandra and how does it improve availability?
Compare Paxos and Raft consensus algorithms.
Explain anti-entropy and how it maintains consistency in eventually consistent systems.
Design a distributed lock service from scratch.
What is linearizability and how does it differ from sequential consistency?
How does Google's Spanner achieve global consistency across data centers?
Design a distributed ID generator that produces unique, roughly-sorted IDs.
What is the FLP impossibility result?
Scalability Patterns
System Design20 questionsWhat is the primary advantage of horizontal scaling over vertical scaling?
Back-pressure allows a consumer to signal a producer to slow its output rate.
Which of the following makes a service stateless?
Explain the bulkhead pattern with a real-world analogy.
What is sticky session and why is it considered an anti-pattern?
True or False: Vertical scaling eliminates the need for stateless service design.
An application server uses in-memory sessions. It has 5 instances behind a load balancer. What problem occurs and how do you fix it?
What is the difference between performance and scalability?
How does queue-based load leveling prevent system overload?
What are the 12-Factor App principles and why do they enable scalability?
A service makes calls to 3 external APIs. One API becomes slow. How does bulkhead help?
Explain the X, Y, Z axes of the Scale Cube.
What is Amdahl's Law parallel limit for a system where 5% of work must be sequential?
What is the primary advantage of Scalability Patterns?
Design a system that scales from 100 users to 1 million users over 12 months.
What is Amdahl's Law and how does it limit horizontal scaling?
How do you implement graceful shutdown to support auto-scaling?
Design an auto-scaling strategy for a video transcoding service with highly variable load.
How do you scale a WebSocket service horizontally?
Design a system to handle Black Friday traffic (100x normal load) for an e-commerce site.
Design: URL Shortener (TinyURL)
System Design Cases22 questionsWhat HTTP status code should a URL shortener return for a permanent redirect?
With Base62 encoding using 6 characters, how many unique short URLs can be generated?
Which ID generation strategy avoids collisions entirely without database lookups?
A URL shortener has 100M URLs and uses MD5 hash truncated to 6 Base62 chars. What is the main risk?
Two users simultaneously request a custom alias 'mylink'. How do you handle this safely?
Your URL shortener's Redis cache suddenly goes down. What happens to the system?
Your URL shortener goes viral — a single short URL is clicked 1 million times per second. How do you handle this 'hot key' problem?
Why would you use Cassandra for analytics instead of PostgreSQL?
What caching eviction policy is most appropriate for URL shortener cache?
You need to add a feature: 'show all URLs created by user X'. How does this affect your database design?
What is the purpose of a 'tombstone' record when a short URL is deleted?
How would you design a multi-region active-active URL shortener with no single region as master?
What is the read/write ratio typically assumed for a URL shortener?
A customer complains that clicking a link shows 'URL not found' even though the link was created 1 hour ago. What could cause this?
Should you use 301 or 302 redirect for maximum analytics accuracy? What are the trade-offs?
Your URL shortener needs to handle 350,000 redirect requests/sec at peak. How many Redis nodes do you need, assuming each handles 100,000 ops/sec?
How would you implement link expiration at scale without scanning the entire database?
How would you prevent your URL shortener from being used to spread malicious links?
Which data store is most appropriate for storing the core short_code → long_url mapping at scale?
How would you migrate from auto-increment IDs to Snowflake IDs in a live production system with zero downtime?
What happens when the same long URL is shortened twice by two different users?
You want to guarantee that a short URL redirect returns in <10ms p99. Which architecture achieves this?
Design: Chat System (WhatsApp/Slack)
System Design Cases22 questionsWhy is WebSocket preferred over HTTP for a chat application?
Alice is connected to Chat Server 1. Bob is connected to Chat Server 2. Alice sends Bob a message. How is it delivered?
Why is Cassandra chosen for message storage over PostgreSQL?
A chat server crashes while 50,000 users are connected. What happens to their messages and connections?
What does 'delivered' status mean vs 'read' status in WhatsApp?
You have a group chat with 100,000 members (think a public community). Someone sends a message. How do you fan-out?
How do you implement 'message ordering' when messages arrive out of order due to network issues?
How many WebSocket servers are needed for 100 million concurrent connections, if each server handles 50,000 connections?
A user receives 1,000 notifications while their phone is off. When they turn it on, what should happen?
Explain how you would implement end-to-end encryption for group messages.
What is the purpose of a Hybrid Logical Clock (HLC) in a distributed chat system?
How do you handle typing indicators without overloading the server?
What is the role of Kafka in the chat message pipeline?
Design the unread message count feature. How do you efficiently show '5 unread' per conversation?
Your Kafka cluster goes down. What happens to message delivery?
What Cassandra partition key design supports efficient message retrieval for a conversation?
How would you design message search ('find all messages containing hello') at scale?
What is the difference between push notifications and WebSocket delivery? When do you use each?
What mechanism prevents a message from being delivered twice if the sender retries due to network timeout?
A chat server needs to be deployed with zero downtime. How do you drain WebSocket connections?
How do you handle the case where two users send messages to each other at the exact same millisecond?
What is the 'session affinity' or 'sticky session' problem with WebSocket servers?
Design: News Feed (Facebook/Twitter)
System Design Cases22 questionsWhat is 'fan-out on write' in the context of a news feed?
A celebrity has 50 million followers and posts 10 times per day. Fan-out on write generates how many feed updates per day?
Why is cursor-based pagination preferred over offset-based for news feeds?
A user follows both Taylor Swift (50M followers) and a friend (100 followers). How do you merge their posts into one ranked feed?
What data structure in Redis is best for storing a user's feed (ordered list of post IDs)?
Your Kafka fan-out workers fall behind during a viral event. Followers see the post 10 minutes late. How do you handle this?
How do you efficiently count likes on a post when 1 million people like it within 1 minute?
What is the 'thundering herd' problem in a news feed system?
How would you design the 'who liked this post' feature showing mutual friends first?
How do you prevent a user from seeing posts they've already seen when infinite scrolling loads the next page?
Which signal is most important for ranking a post higher in the news feed?
A user deactivates their account. How should this affect the news feed of their 10,000 followers?
What is the difference between a chronological feed and an algorithmic feed? What are the trade-offs?
How should media uploads be handled to avoid overloading the post service?
Your Redis cluster storing feed caches goes down. What is the fallback strategy?
How would you implement hashtag-based trending topics?
What approach does Facebook use to serve a single user's news feed from pre-computed data?
How do you ensure a user never sees a post they blocked or from a user they blocked?
How would you design A/B testing for news feed ranking algorithms?
What technique avoids the N+1 query problem when hydrating a list of 50 post IDs from cache?
A new user signs up and follows 0 people. What do you show in their empty feed?
How would you handle the news feed for a user who follows 10,000 accounts (power user)?
JavaScript Fundamentals
Programming Languages34 questionsWhich statement about let and var is TRUE?
What does console.log(typeof null) output?
What is the difference between == and ===?
Where does the prototype chain end?
What is the difference between forEach and map?
What is the difference between null and undefined in JavaScript?
What is a closure in JavaScript?
What is the Temporal Dead Zone (TDZ)?
What does Promise.all do if one promise rejects?
What output? ```javascript const obj = { x: 1 }; const copy = obj; copy.x = 2; console.log(obj.x); ```
What is hoisting and how does it differ for var, let, const, and function declarations?
What is the difference between call, apply, and bind?
What does Object.freeze do?
What does the async keyword do to a function's return value?
What is optional chaining (?.) and nullish coalescing (??)?
What does Array.prototype.reduce do? Implement sum.
Predict output: ```javascript const a = [1, 2, 3]; const b = [...a]; b.push(4); console.log(a.length, b.length); ```
What output does this produce? ```javascript for (var i = 0; i < 3; i++) { setTimeout(() => console.log(i), 0); } ```
Implement a memoize function that caches results by arguments.
What are the 4 rules of this binding in order of precedence?
What is the difference between __proto__ and prototype?
How do arrow functions differ from regular functions regarding this?
What is a generator function and when would you use one?
Explain event delegation and why it is useful.
What is a WeakMap and how does it differ from Map?
Implement a once function — callable only once, returning cached result thereafter.
Explain the JavaScript event loop and the difference between microtasks and macrotasks.
What does this output? ```javascript console.log('1'); setTimeout(() => console.log('2'), 0); Promise.resolve().then(() => console.log('3')); console.log('4'); ```
Implement debounce from scratch.
Explain synchronous vs asynchronous error handling.
Implement throttle from scratch.
What is the Proxy object used for?
Implement Promise.all from scratch.
Design a pub/sub EventEmitter in JavaScript.
React
Frontend32 questionsWhat are the two rules of React hooks?
What does the dependency array in useEffect do?
What is the difference between useMemo and useCallback?
What is reconciliation in React?
What does React.memo do?
What is the difference between controlled and uncontrolled components?
What is the Context API and when would you use it?
What does useRef do and when would you use it?
What is prop drilling and how do you solve it?
What is the purpose of the key prop?
What happens when you return a function from useEffect?
What output does this produce on the first render? ```jsx function Component() { const [count, setCount] = useState(0); useEffect(() => { setCount(count + 1); }, []); return <div>{count}</div>; } ```
When should you use useReducer instead of useState?
What is a stale closure in React?
Why should you not use array index as a key in React lists?
What causes infinite re-render loops in React?
What is the difference between server components and client components in Next.js?
How does useCallback help performance?
What is an error boundary and why must it be a class component?
What does React.lazy and Suspense do?
What is forwardRef used for?
What is the difference between useState initializer and useState with a function argument?
Implement a useLocalStorage custom hook.
Implement a useDebounce hook.
What is the compound component pattern?
Explain React Fiber.
What is the useTransition hook used for?
How would you implement optimistic updates in React?
What is the difference between useLayoutEffect and useEffect?
Why does React StrictMode double-invoke effects in development?
Implement useFetch — a hook that fetches data from a URL.
What are React Server Components and what problem do they solve?
SQL
Databases31 questionsWhat does LEFT JOIN return when there is no matching row in the right table?
What does `NULL + 1` evaluate to in SQL?
True or False: A FULL OUTER JOIN returns all rows from both tables, including unmatched rows from each.
What is the difference between a primary key and a unique constraint?
What is the purpose of `COALESCE` in SQL?
What is the difference between WHERE and HAVING?
What is the difference between RANK() and DENSE_RANK()?
What are the four ACID properties?
What is the difference between TRUNCATE and DELETE?
What does `COUNT(col)` vs `COUNT(*)` count?
Write a query to find customers who have placed more than 3 orders.
What is a self-join and when would you use one?
What does the SQL `EXISTS` operator do?
What is SQL injection and how do you prevent it?
Arrange these SQL clauses in their logical execution order: HAVING, FROM, SELECT, WHERE, GROUP BY, ORDER BY
What is the difference between UNION and UNION ALL?
Write a SQL query to find the second-highest salary.
Explain what a composite index is and how column order matters.
What is a correlated subquery and why can it be slow?
What is an index-only scan?
What is the N+1 query problem in SQL?
What is a covering index?
What is a deadlock in a database and how is it resolved?
What does `EXPLAIN ANALYZE` show in PostgreSQL?
What is the difference between a clustered and non-clustered index?
What is a window function PARTITION BY and how does it differ from GROUP BY?
How would you find duplicate rows in a table?
What is `JSONB` in PostgreSQL and why is it preferred over `JSON`?
Write a query using a window function to get the top 3 salaries per department.
Write a recursive CTE to traverse an employee hierarchy and show all subordinates of a manager.
What are transaction isolation levels and what phenomena do they prevent?
OOP & Design Patterns
Software Engineering30 questionsWhat does the 'O' in SOLID stand for and how do you achieve it?
What is Dependency Injection and why does it make code more testable?
What is the Observer pattern and where does it appear in real systems?
What is the difference between the Adapter and Facade patterns?
True or False: The Singleton pattern is always an antipattern.
What is the Repository pattern and why is it useful?
What is a God Class and how do you fix it?
What is the Interface Segregation Principle?
Explain the Builder pattern and when to use it over a constructor with many parameters.
What is 'Feature Envy' code smell?
Arrange these in the order of abstraction from lowest to highest: Implementation, Interface, Concrete Class, Abstract Class
True or False: The Observer pattern and Publish/Subscribe (pub/sub) pattern are identical.
What pattern do middleware systems (Express, Django, Laravel) implement?
What is the Liskov Substitution Principle and give an example of a violation?
What is the difference between the Factory Method and Abstract Factory patterns?
What problem does the Decorator pattern solve that subclassing cannot?
Implement the Singleton pattern in TypeScript with lazy initialization.
What is the Strategy pattern and how does it support the Open/Closed Principle?
What is the Command pattern and how does it enable undo functionality?
What is the Composite pattern?
What is the Template Method pattern and where does it appear in frameworks?
What is the Chain of Responsibility pattern?
What is 'Shotgun Surgery' antipattern and which SOLID principle does it violate?
What is the difference between Composition and Aggregation in OOP?
What is 'Primitive Obsession' and how do you fix it?
What is the Null Object pattern?
What is the Single Responsibility Principle in practice — how do you identify when a class has too many responsibilities?
What is the difference between the Proxy and Decorator patterns?
What is the Flyweight pattern and when is it useful?
Design a logging system using the appropriate design pattern that supports multiple outputs (console, file, network) and log levels.
Operating Systems
Computer Science Fundamentals30 questionsTrue or False: The heap and stack grow in opposite directions in a typical process address space.
What is the purpose of the PCB (Process Control Block)?
What is the difference between a process and a thread?
What are the four Coffman conditions required for deadlock?
What is virtual memory and why does every process need its own?
What is a race condition? Give a concrete example.
What is a zombie process?
Explain the Round Robin scheduling algorithm and its tradeoffs.
What is the difference between fork() and exec()?
What does an inode contain?
What is a context switch and what information is saved/restored?
What are Unix signals and give 3 examples?
What is the difference between a hard link and a symbolic (soft) link?
What is the difference between preemptive and cooperative (non-preemptive) scheduling?
What is an orphan process?
What is the /proc filesystem in Linux?
What is the difference between a mutex and a semaphore?
What is a page fault and what happens when one occurs?
What is thrashing in OS and what causes it?
What is a condition variable and why must the condition be checked in a while loop?
What is copy-on-write (COW) and how does it make fork() efficient?
What is a spinlock and when is it appropriate?
What is the purpose of the TLB (Translation Lookaside Buffer)?
What is memory fragmentation and what are its two types?
What is the difference between a major and minor page fault?
Arrange these CPU scheduling metrics from the perspective of an interactive user from most important to least: Throughput, Response time, Turnaround time, Waiting time
What does the kernel do during a system call?
What is a binary semaphore and how does it differ from a mutex?
Explain the concept of CPU affinity and when you would use it.
What are Linux namespaces and how do they enable containers?
Networking
Computer Science Fundamentals30 questionsWhat does HTTPS add over HTTP?
What is the difference between GET and POST in REST APIs?
What is the difference between authentication and authorization?
What HTTP status code should you return when a client sends a valid request but doesn't have permission?
What is the difference between TCP and UDP?
Describe the TCP 3-way handshake.
Explain the DNS resolution process step by step.
What is a certificate authority and why is it needed for TLS?
What is CORS and why does it exist?
What is the difference between a 301 and 302 redirect?
What is an idempotent HTTP method?
True or False: WebSockets use HTTP for the initial connection.
What are the three parts of a JWT?
What is a CDN and how does it reduce latency?
What is the purpose of the OPTIONS HTTP method?
What is DNS TTL and what are the tradeoffs of low vs high TTL?
What is the difference between 400, 401, 403, and 404 status codes?
Arrange these layers from closest to hardware (lowest) to closest to the user (highest): Transport, Application, Network, Physical
What is the difference between HTTP/1.1, HTTP/2, and HTTP/3?
What is head-of-line blocking?
What is the purpose of HTTP headers like Cache-Control, ETag, and Last-Modified?
What is perfect forward secrecy in TLS?
What is the difference between OAuth2 Authorization Code flow and Client Credentials flow?
What is SSL stripping and how does HSTS prevent it?
What is gRPC and when would you choose it over REST?
Explain how HTTP caching with Cache-Control: no-cache differs from Cache-Control: no-store.
What is Server-Sent Events (SSE) and when would you use it instead of WebSockets?
What is TCP's congestion control and why is it needed?
What is Rate Limiting and how would you implement it?
What happens when you type a URL into a browser and press Enter?
Java Core
Programming Languages20 questionsWhat is the output of: String a = "hello"; String b = "hello"; System.out.println(a == b);
Which collection provides O(1) average-case time for get(), put(), and containsKey()?
What happens when you call stream() operations without a terminal operation?
Which keyword ensures a field is NOT serialized when using Java object serialization?
What is the primary difference between synchronized methods and volatile fields?
What does the 'final' keyword mean when applied to a class, a method, and a variable respectively?
Which of these correctly implements a checked exception?
What is the output of: List<Integer> list = Arrays.asList(1, 2, 3); list.add(4);
In Java generics, what does 'List<? extends Number>' allow you to do with the list?
What is the role of Young Generation in JVM garbage collection?
What does the final keyword mean when applied to a method?
Which Java feature allows you to process collections with functional-style operations?
What is the difference between == and .equals() in Java?
What happens when you call HashMap.put() with an existing key?
What is the time complexity of ArrayList.add(0, element)?
What is the difference between checked and unchecked exceptions?
What is the output of: System.out.println(10 + 20 + "Hello" + 10 + 20)?
Which collection should you use for thread-safe key-value operations?
What is the purpose of the volatile keyword in Java?
What is the purpose of the transient keyword?
DSA Coding Patterns
Algorithms13 questionsWhat is the time complexity of binary search?
What pattern would you use for 'find the longest substring without repeating characters'?
What pattern for 'next greater element' problems?
When should you use BFS over DFS?
What data structure for 'find median in a stream'?
What is the time complexity of Union-Find with path compression and union by rank?
What is the primary advantage of DSA Coding Patterns?
When should you NOT use DSA Coding Patterns?
What is the time complexity of the core operation in DSA Coding Patterns?
How does DSA Coding Patterns handle failures?
Which company popularized the use of DSA Coding Patterns?
In the Two Pointers pattern for Container With Most Water, why do you move the shorter pointer?
When does greedy NOT work?
Content Delivery Networks (CDN)
System Design20 questionsWhat does a CDN cache HIT mean?
Which Cache-Control directive tells shared caches (CDN) to cache for 1 hour, but browser should revalidate?
Push CDN pre-loads content to edge nodes before any user requests it.
What is origin shield and why is it important for high-traffic sites?
What is content versioning and why is it better than CDN purging for static assets?
A new product is launching at midnight with 1M users expected. How do you use CDN to prepare?
How does the Vary header affect CDN caching?
Design a CDN caching strategy for an e-commerce product catalog with real-time pricing.
What is the difference between CDN-level DDoS protection and application-level rate limiting?
How do you cache authenticated API responses in a CDN?
What is a Surrogate Key (Cache Tag) and which CDNs support it?
True or False: Cloudflare Workers can modify the response from origin before sending to user.
Design a CDN architecture for a live video streaming platform.
How does Anycast routing help CDN route users to the nearest edge node?
What HTTP status code does a CDN return for a conditional request when content hasn't changed?
How does Netflix Open Connect CDN differ from public CDN providers?
What is a cache poisoning attack on a CDN and how do you prevent it?
Calculate the CDN cache hit ratio needed to save $1M/year if origin bandwidth costs $0.10/GB and CDN bandwidth costs $0.01/GB at 10PB/month.
True or False: Using a CDN always improves performance for all types of content.
What is the primary advantage of Content Delivery Networks (CDN)?
Rate Limiting & Throttling
System Design20 questionsWhat HTTP status code should a rate limiter return when a limit is exceeded?
Which rate limiting algorithm allows a burst of requests followed by a sustained rate?
The leaky bucket algorithm smooths output regardless of input burst rate.
Explain the boundary burst problem with fixed window rate limiting.
Implement a token bucket rate limiter in Redis that allows 10 RPS with burst of 50.
How do you implement distributed rate limiting across 10 API server instances?
What is the sliding window counter approximation and what is its error bound?
Design rate limiting for a payment API that processes financial transactions.
What are the trade-offs between rate limiting at the CDN edge vs at the application?
True or False: Rate limiting and circuit breaking serve the same purpose.
A user hits the rate limit. What should the API response include?
How do you implement rate limiting that doesn't have Redis as a single point of failure?
Explain the token bucket implementation in AWS API Gateway.
Design a rate limiter for a SaaS API with 3 tiers: Free (100/day), Pro (10k/day), Enterprise (unlimited).
What is adaptive rate limiting and when would you use it?
How does rate limiting interact with retry logic in API clients?
What is the primary advantage of Rate Limiting & Throttling?
When should you NOT use Rate Limiting & Throttling?
What is the time complexity of the core operation in Rate Limiting & Throttling?
How does Rate Limiting & Throttling handle failures?
Authentication & Authorization
System Design20 questionsWhat is the difference between authentication and authorization?
A JWT access token should be stored in localStorage for a web application.
Which password hashing algorithm is recommended for storing user passwords?
Explain the OAuth 2.0 authorization code flow step by step.
How do you revoke a JWT token that hasn't expired yet?
Design an authentication system for 50 microservices.
What is PKCE in OAuth 2.0 and why is it required for public clients?
Compare RBAC and ABAC. When would you use each?
How does mTLS provide authentication for service-to-service communication?
What is zero-trust architecture and how does it differ from perimeter-based security?
True or False: OAuth 2.0 access tokens should be stored in browser cookies.
Design a multi-tenant authorization system for a SaaS application.
How do you implement single sign-on (SSO) for 5 web applications?
What is a confused deputy attack in authorization?
How do you securely implement 'remember me' / persistent login?
What is OpenID Connect (OIDC) and how does it extend OAuth 2.0?
Implement password reset flow securely.
How do you propagate user identity across microservices?
What is the primary advantage of Authentication & Authorization?
When should you NOT use Authentication & Authorization?
Monitoring & Observability
System Design20 questionsWhat are Google's Four Golden Signals?
What does SLO stand for and what is it used for?
Prometheus uses a push model to receive metrics from services.
Explain the difference between a trace, a span, and a trace ID.
What is the error budget for a service with a 99.9% SLO over a 30-day period?
Design an observability strategy for a microservices e-commerce platform with 30 services.
What is high cardinality in metrics and why is it a problem for Prometheus?
Compare Prometheus and Datadog for production monitoring.
How do you implement distributed tracing without modifying every service's code?
What is a Prometheus Counter vs Gauge vs Histogram?
True or False: SLA should be set equal to your internal SLO.
Design alerting for a payment API with 99.95% SLO using error budget burn rate.
What is MTTD and MTTR? How do you minimize each?
How do you correlate logs, metrics, and traces for a single request?
What is synthetic monitoring and how does it complement real-user monitoring?
What is log aggregation and why is it necessary in a microservices environment?
Design an on-call rotation and incident response process for a 6-engineer team.
What is the primary advantage of Monitoring & Observability?
When should you NOT use Monitoring & Observability?
What is the time complexity of the core operation in Monitoring & Observability?
Networking Fundamentals
System Design20 questionsWhat is the main advantage of HTTP/2 over HTTP/1.1?
Why does DNS primarily use UDP instead of TCP?
WebSocket connections work over standard HTTP ports (80/443).
Explain what happens at each step when you type 'https://google.com' in a browser.
What is head-of-line blocking and how does HTTP/2 address it?
When would you choose WebSocket over SSE for a real-time application?
Compare gRPC and REST for an internal microservice API. Which would you choose?
Explain TLS certificate chain validation.
How does QUIC (HTTP/3) improve on TCP+TLS?
True or False: HTTP/3 uses TCP as its transport protocol.
Design a protocol for a real-time multiplayer game.
What is the difference between a CNAME and an A record in DNS?
Explain how long polling works and what its limitations are.
How do you handle WebSocket connections across multiple server instances?
What is HPACK header compression in HTTP/2 and why is it important?
What is TCP congestion control and how does it affect application performance?
What is the primary advantage of Networking Fundamentals?
When should you NOT use Networking Fundamentals?
What is the time complexity of the core operation in Networking Fundamentals?
How does Networking Fundamentals handle failures?
Data Storage & Processing
System Design20 questionsWhat is the main difference between a data lake and a data warehouse?
Why is Parquet preferred over CSV for analytics workloads?
Apache Flink processes data as micro-batches, like Spark Streaming.
What is the difference between ETL and ELT?
Design a data pipeline to process 1 billion events per day from user activity on a mobile app.
What is a watermark in stream processing and why is it needed?
Explain the Lambda architecture and its main criticism.
What is Change Data Capture (CDC) and why is it used?
Design a real-time recommendation engine that updates recommendations as users browse.
What is data skew in Spark and how do you fix it?
True or False: Apache Spark can only process batch data, not real-time streams.
What is a star schema and how does it differ from OLTP schema design?
How do you ensure exactly-once processing in a stream processing pipeline?
What is Parquet and what are its key benefits for data analytics?
Design a system to track real-time inventory levels across 10,000 warehouses.
Explain the concept of event time vs processing time in stream processing.
What is dbt and how does it fit into the modern data stack?
What is the primary advantage of Data Storage & Processing?
When should you NOT use Data Storage & Processing?
What is the time complexity of the core operation in Data Storage & Processing?
Design: Rate Limiter
System Design Cases22 questionsWhich HTTP status code indicates a rate limit has been exceeded?
What is the main disadvantage of a fixed window counter rate limiter?
Why must the sliding window check-and-increment be done atomically in Redis?
Your rate limiter Redis cluster goes down during peak traffic. What should happen?
Which algorithm allows bursting up to bucket capacity while maintaining an average rate?
How do you rate limit a distributed denial-of-service (DDoS) attack from 10,000 different IP addresses?
A sliding window log stores every request timestamp. For 100 req/min limit with 10M users, how much Redis memory is needed?
An API has a limit of 1000 requests/hour. A user sends 999 requests in the first minute. What should happen for the remaining 59 minutes?
How would you implement different rate limits for free vs paid users?
What Redis command makes a rate limit counter expire automatically after the window?
How do you rate limit an API endpoint that is called from a mobile app where users share the same NAT IP?
How would you design a rate limiter that limits by cost rather than by count (e.g., expensive ML inference costs 10 units, simple lookup costs 1)?
Which header tells a client when their rate limit window resets?
You need to rate limit across 5 Redis shards. A user's requests may hit different shards. How do you ensure consistent counting?
How does the leaky bucket algorithm differ from token bucket, and when would you choose it?
Where should a rate limiter be implemented in the request pipeline?
An attacker makes exactly 99 requests per minute (limit is 100) from 1000 different user accounts. How do you detect and block this?
What are the trade-offs between implementing rate limiting at the application level vs at a reverse proxy (like NGINX)?
What is the 'sliding window counter' algorithm's approximation error rate?
How do you test that your rate limiter is working correctly in production without impacting users?
Design a rate limiter for a GraphQL API where a single request can include multiple queries.
What Redis data structure is used for implementing sliding window log rate limiting?
Design: Web Crawler
System Design Cases22 questionsWhy is BFS (Breadth-First Search) preferred over DFS for web crawling?
What is the purpose of a Bloom filter in a web crawler?
A website generates infinite unique URLs like /products?page=1, /products?page=2 ... /products?page=1000000. How do you handle this?
What does robots.txt's 'Crawl-delay: 10' directive mean?
How do you crawl JavaScript-rendered Single Page Applications (SPAs)?
A fetcher node crashes after popping a URL from the queue but before completing the crawl. How do you prevent URL loss?
How does SimHash detect near-duplicate web pages?
What is the 'politeness' policy in web crawling?
You crawl a page at URL A which has identical content to URL B (a mirror site). How do you avoid indexing duplicates?
How should a crawler handle a 404 Not Found response?
How would you prioritize which URLs to crawl first with a limited crawl budget?
What is the false positive rate of a Bloom filter configured with 10 bits per element and 7 hash functions?
How do you handle a website that requires JavaScript and login to access content?
Why is URL normalization important for deduplication?
Which partitioning strategy for the URL frontier prevents a single fast-to-crawl domain from monopolizing crawlers?
How would you design the crawler to handle DNS lookups efficiently at 400 pages/second?
What is the difference between crawl depth and crawl breadth? How do you balance them?
What User-Agent header should a well-behaved crawler send?
Your crawler generates 400,000 duplicate URLs per second (from link extraction). How do you efficiently deduplicate this volume?
How would you design a recrawl scheduler that decides when to recrawl each page?
How does a web crawler handle redirect chains (301, 302)?
How would you scale the crawler from 400 pages/sec to 4,000 pages/sec?
Design: Notification System
System Design Cases22 questionsWhat is the difference between FCM and APNS?
What happens when you try to send a push notification to an invalid/expired device token?
How do you implement 'quiet hours' — not sending notifications between 10pm and 8am in user's local time?
Your email notification service sends 2 million emails/day. SendGrid has a 4-hour outage. How do you handle this?
What legal requirement mandates that marketing emails include an unsubscribe link?
You need to send a promotional notification to 50 million users at 9am in their local timezone. How do you architect this?
How do you prevent notification fatigue — users getting too many notifications and turning them off?
What is a Dead Letter Queue (DLQ) in a notification system?
A user has 5 devices (phone, tablet, 2 computers, smart TV). How do you manage notifications across all of them?
How do you design idempotent notification delivery to prevent duplicate sends?
A notification system sends 1,000 notifications/sec. Each notification requires one database read for user preferences. How do you avoid overloading the database?
How do you handle email bounces and complaints to protect your email sending reputation?
Design the notification system's template versioning — how do you update a template without breaking in-flight notifications?
What is the purpose of a tracking pixel in email notifications?
Your notification system needs to support A/B testing different push notification copy. How do you implement this?
What is 'send time optimization' in notification systems?
How do you handle a scenario where FCM rate limits your push notifications?
How would you design notification preferences for a complex hierarchy: global mute → category mute → channel mute?
What is the recommended way to handle a user who uninstalls your app but still has their device token in your database?
How do you guarantee an OTP (one-time password) SMS is delivered within 30 seconds?
What is the difference between transactional and marketing notifications? Why does it matter architecturally?
What is 'notification deduplication window' and why is it important?
Design: E-Commerce System (Amazon)
System Design Cases22 questionsWhy is Redis preferred for shopping cart storage over a relational database?
A product has 10 units in stock. 100 users all click 'Buy' simultaneously. How do you prevent overselling?
What is an idempotency key in payment processing?
Why should raw credit card numbers never be stored in your e-commerce database?
During Amazon Prime Day, your checkout service gets 10,000 orders/sec (normally 100/sec). How do you handle this?
How do you handle the case where a user's payment succeeds but the order confirmation email fails to send?
What data structure is best for Elasticsearch product faceted search (filters by brand, price range, category)?
How do you keep Elasticsearch product index in sync with the DynamoDB product catalog?
How would you design the order state machine for an e-commerce system?
How do you shard the orders database to support efficient queries by both user_id and order_id?
How do you handle cart merge when a guest user logs in to an existing account?
How would you design a dynamic pricing system like Amazon's, where prices change multiple times per day?
What is the 'saga pattern' and when is it used in e-commerce?
A seller fraudulently lists 1,000,000 units of an iPhone at $1. How do you detect and prevent this?
How do you implement product recommendations ('Customers who bought X also bought Y')?
What approach prevents a user from seeing stale inventory counts in the product listing?
How do you handle a product return and refund flow?
How would you design a seller portal for inventory management at scale (millions of sellers)?
What is the purpose of storing the price in the cart (price snapshot) at add time?
How do you design a global e-commerce system where inventory is shared between multiple geographic fulfillment centers?
How do you calculate and display shipping estimates accurately?
What happens if the inventory reservation succeeds but the database write for the order record fails?
Design: Video Streaming Platform (YouTube/Netflix)
System Design Cases22 questionsWhy is video transcoding necessary before streaming?
What is HLS (HTTP Live Streaming)?
Why are CDN cache TTLs set to very long (1 year) for video segments?
A creator uploads a 2-hour 4K video. How do you transcode it in under 5 minutes?
How does adaptive bitrate streaming decide which quality to serve?
A viral video suddenly gets 10 million concurrent viewers. How does your CDN handle this?
Why does YouTube use view count approximations (e.g., 1.2M views, not 1,234,567)?
How do you implement 'resume from where you left off' for video playback?
What is the purpose of a 'master playlist' in HLS?
How do you detect and remove videos that violate copyright (like YouTube's Content ID)?
How would you design the recommendation system to avoid the 'rabbit hole' effect (showing increasingly extreme content)?
What is 'pre-fetching' in video streaming and why does it matter?
How do you handle video thumbnail generation at scale?
Why is progressive download (HTTP byte-range) inferior to HLS/DASH for streaming?
A transcoding job for a 3-hour movie takes 45 minutes. How do you parallelize it?
How would you design the analytics pipeline to show creators 'audience retention' — which second of their video viewers drop off?
How do you handle a creator deleting a video that is currently being watched by 100,000 users?
What metric best indicates whether your video streaming quality is good?
How would you design automatic subtitle/caption generation for every uploaded video?
How would you design a video search system that understands what's in the video (not just title/tags)?
What is 'time-to-first-frame' and why is it critical for video platforms?
How do you implement 'chapters' in YouTube videos (click to jump to specific sections)?
Design: Search Autocomplete (Google)
System Design Cases22 questionsWhat data structure is primarily used for efficient prefix-based autocomplete?
Why is SQL LIKE 'app%' insufficient for autocomplete at Google scale?
What is the 'top-K cache at each node' optimization in a trie?
How do you update the trie when query frequencies change, without causing serving errors?
Why should autocomplete requests be debounced on the client side?
How do you detect and boost trending queries in autocomplete?
How do you handle race conditions when a user types quickly and multiple autocomplete requests are in-flight?
How would you implement personalized autocomplete without violating user privacy?
What caching layer can serve 80% of autocomplete traffic without hitting the application server?
How do you support autocomplete in Chinese, which uses thousands of unique characters?
How would you design autocomplete for voice search (spoken query autocomplete)?
What is the time complexity of finding top-5 suggestions for a given prefix in an optimized trie with top-K caching?
A user searches for inappropriate content and it starts showing up as an autocomplete suggestion. How do you handle this?
What is the trade-off between trie depth limit and suggestion quality?
What is an alternative to trie for autocomplete that Redis supports natively?
How do you handle the autocomplete system when a major news event causes a new query ('earthquake 2024') to need immediate autocomplete support?
How would you design autocomplete for a domain-specific search (e.g., medical queries) vs general web search?
How frequently should the trie be updated from new query frequency data?
How do you estimate the memory needed to store a trie for the top 1 million English search queries?
How would you design a spell-correction feature that works alongside autocomplete?
What is 'query normalization' in the context of building autocomplete frequency data?
How would you scale autocomplete to 3 million requests per second (10x Google's current scale)?
Design: Distributed Key-Value Store (Redis/DynamoDB)
System Design Cases22 questionsWhat does the CAP theorem state?
What is the advantage of consistent hashing over modulo hashing for data distribution?
For N=3 replicas, W=2 writes, R=2 reads: is strong consistency achieved?
Two clients simultaneously write different values to the same key on two different nodes (network partition). How do you resolve this conflict?
What is the purpose of virtual nodes (vnodes) in consistent hashing?
Explain the LSM-tree write path and why it's faster than B-tree for write-heavy workloads.
What is a Bloom filter used for in an LSM-tree based KV store?
A node fails and recovers after 2 hours. How do you ensure it has consistent data?
What is 'eventual consistency' in a distributed KV store?
How does the gossip protocol help detect node failures in a distributed KV store?
What is 'hinted handoff' and what problem does it solve?
How do you implement TTL expiration for 1 billion keys without scanning all of them every second?
What are CRDTs and when should a KV store use them instead of last-write-wins?
What is the purpose of a Write-Ahead Log (WAL) in a KV store?
Your KV store cluster needs to add 10 new nodes to increase capacity. How do you do this without downtime?
When would you choose a KV store over a relational database? Give three specific scenarios.
What problem does Merkle tree anti-entropy solve in a distributed KV store?
A client reads a key and gets an old value because it hit a stale replica. How do you detect and fix this?
What is the difference between a cache (like Redis) and a persistent KV store (like DynamoDB)? When do you use each?
In the Raft consensus algorithm used by etcd, what is a 'leader election'?
Design a geo-distributed KV store where users in Europe must see EU data, and US users see US data (data residency requirements).
How do you handle a 'hot key' problem where one key (e.g., a celebrity's profile) gets 1 million reads per second?
Design: Ride-Sharing Service (Uber/Lyft)
System Design Cases22 questionsWhy is Euclidean (straight-line) distance insufficient for ETA calculation in a ride-sharing app?
Why must neighboring geohash cells also be queried when searching for nearby drivers?
A driver's phone GPS has a 30-second outage. What happens to ongoing trip tracking?
What Redis data structure is used to store driver locations by geographic cell?
How does surge pricing work and how do you ensure it's fair to riders?
The system matches 10 drivers to the same rider request due to a bug. How do you prevent this?
How do you handle a rider requesting a ride in a very dense area (airport) with 100 simultaneous requests?
How do you scale the location service to handle 500,000 driver updates per second?
What communication protocol is used to push driver location updates to the rider app in real time?
How do you detect and prevent GPS spoofing (a driver faking their location)?
How does the app show an accurate ETA for driver arrival that updates in real time?
A driver rejects a ride offer. What happens next?
How do you implement 'share my trip' safety feature that lets a rider share live location with a contact?
How would you design the ML system for proactive driver positioning (predicting where demand will be)?
What geospatial precision (geohash length) should be used for finding drivers within 2km?
How do you handle a trip that goes through a tunnel with no GPS signal?
What is the difference between H3 and Geohash for geospatial indexing? When would you use each?
How does the system ensure a driver is charged the correct distance even if their GPS has gaps?
How would you design a pool/shared ride matching system where two riders going the same direction share a car?
How do you build the driver rating system to prevent gaming?
What database is most appropriate for storing driver location history for audit and analytics purposes?
A major event (concert) ends and 50,000 people simultaneously request rides. How does the system handle this?
Design: Social Media Platform (Instagram)
System Design Cases22 questionsWhy are multiple image size variants (thumbnail, medium, large) generated for each uploaded photo?
How does Instagram handle the 'celebrity problem' where Selena Gomez (400M followers) posts a photo?
How are Instagram Stories automatically deleted after 24 hours?
A photo uploaded by a user is found to violate content policy 1 hour after posting. How do you handle this?
How do you implement the 'story ring' — showing circles of friends who have active stories?
How is the like count for a photo stored and retrieved at 49,000 likes/sec?
How do you detect and prevent upload of child sexual abuse material (CSAM)?
How would you design the 'close friends' feature where stories are shared with a select group?
How do you store the follower graph for 2 billion users with an average of 200 follows each?
How would you design the Instagram Explore page recommendation system?
What is a perceptual hash (pHash) used for in image upload processing?
A user with 10M followers posts a photo. How does it appear in followers' feeds?
Why does Instagram use Cassandra for storing media metadata instead of MySQL?
How do you implement 'suggested users to follow' based on social graph connections?
What is the purpose of cursor-based pagination in Instagram's feed vs offset pagination?
How do you handle video upload and playback at scale (Reels)?
How would you design the 'tagged in a photo' feature and make it searchable?
How does Instagram ensure images load quickly for users in slow network regions?
A user deletes their Instagram account. What needs to happen to their data?
How would you design a visual search feature ('search by image')?
What technique prevents the same user from liking a photo multiple times?
How would you design the hashtag trending system for Instagram?
Design: Payment System (Stripe/PayPal)
System Design Cases22 questionsWhat is an idempotency key in payment processing?
Why should monetary amounts be stored as integers (cents) rather than floats?
What is double-entry bookkeeping and why is it used in payment systems?
The payment gateway times out after 10 seconds. You don't know if the charge succeeded. What do you do?
What does PCI DSS require regarding storage of credit card numbers?
How do you design webhook delivery to guarantee at-least-once delivery to merchants?
A merchant has a chargeback rate of 2%. What action should the payment system take?
Your payment processing system needs to handle a payment gateway outage. How do you design failover?
Explain how a refund is processed end-to-end, including ledger entries.
What is a payment 'authorization' vs 'capture'?
How do you handle a situation where your internal ledger shows a different balance than the bank?
What is HMAC-SHA256 signature verification used for in webhook delivery?
How would you design a real-time fraud detection system that operates in <50ms?
Two concurrent requests with the same idempotency key arrive simultaneously. How do you handle this?
A merchant wants to implement a subscription billing system. How do you design this?
How do you support multiple currencies in a payment system?
What is a chargeback?
How would you design instant payouts (money in merchant's bank within 30 seconds)?
How would you design a marketplace payment system (like Airbnb) where payment flows through a platform to sellers?
What is 3D Secure (3DS) authentication used for?
What is the difference between a payment gateway and a payment processor?
How do you implement payment retries safely when a customer's card is declined?
Design: File Storage System (Google Drive/Dropbox)
System Design Cases22 questionsWhy is chunked upload better than single-file upload for large files?
What hash function is used for block-level deduplication fingerprinting?
User A edits a file on their laptop while offline. User B edits the same file online. When A reconnects, how do you handle the conflict?
What is 'delta sync' and why does it matter?
How does block-level deduplication work when the same file is uploaded by 1000 users?
How do you implement real-time collaborative editing (multiple users editing same doc simultaneously) like Google Docs?
How do you handle permissions when a folder is shared with 'view' access but contains a subfolder with 'edit' access for a different user?
How do you implement chunk garbage collection safely?
What is content-defined chunking (CDC) and how does it improve deduplication?
A user accidentally deletes a folder with 10,000 files. How do you implement 'restore from trash'?
How do you design the sync service to handle a user with 10 devices?
How are large file downloads made efficient and resumable?
How do you implement enterprise file retention / legal hold (e-discovery)?
What is the purpose of storing a content hash (SHA-256) for the entire file separately from chunk hashes?
What strategy does Dropbox use for conflict resolution when two users edit the same file simultaneously?
How do you implement file sharing via a public link (anyone with link can view)?
How would you design cross-region replication for file storage to ensure durability?
What is tiered storage and why does it matter for a file storage service?
How do you handle a user uploading 10,000 small files (1KB each) simultaneously?
How do you implement versioning with a retention limit (e.g., keep only last 30 versions)?
Why is the file sync service better implemented with WebSocket notifications rather than polling?
How do you implement data loss prevention (DLP) — detecting when sensitive data (credit cards, SSNs) is uploaded?
Design: Distributed Task Scheduler (Cron at Scale)
System Design Cases22 questionsWhy is a single-server cron scheduler not suitable for production at scale?
What is the purpose of leader election in a distributed task scheduler?
A worker picks up a task and starts executing. The worker crashes mid-execution. What happens?
What is the 'thundering herd' problem in a task scheduler?
How do you calculate the next_run_at for a cron expression after a successful execution?
What Redis command is used to implement a distributed lock for exactly-once task execution?
You have 1 million tasks due in the next second (month-end batch processing). How do you handle this?
How do you implement a dead letter queue (DLQ) for tasks that exhaust all retries?
What is the difference between 'at-least-once' and 'exactly-once' task execution?
How would you design task dependency — Task B runs only after Task A completes successfully?
Why must the database index on tasks include both next_run_at AND status?
A task is supposed to run every minute, but due to a 5-minute outage, 5 executions were missed. What should happen on recovery?
What types of task execution does a scheduler need to support (HTTP callback, etc.)?
What happens if the ZooKeeper cluster used for leader election goes down?
How do you implement a 'paused' state for a recurring task that should not execute during system maintenance?
How do you design the scheduler to guarantee task execution within 1 second of scheduled time at scale?
What is 'jitter' in the context of retry strategies?
A task has max_execution_time of 5 minutes but the external service it calls hangs indefinitely. What happens?
How would you implement task deduplication — ensuring a task that should run once per day doesn't accidentally run twice?
A recurring task has been running every minute for a year. It has 525,600 execution log entries. How do you manage this data growth?
How would you design a multi-tenant scheduler where thousands of different teams use the same infrastructure?
Why should a task scheduler use atomic database operations (UPDATE with WHERE clause) when claiming tasks?
TypeScript
Programming Languages32 questionsWhat is the difference between type and interface in TypeScript?
What does Partial<T> do?
Implement MyPartial<T> from scratch using mapped types.
What is a discriminated union? Give an example.
What does the infer keyword do in a conditional type?
What is the difference between unknown and any?
What does keyof T produce?
What is a type predicate and when do you use it?
Implement DeepReadonly<T> — makes all nested properties readonly.
What is never in TypeScript and when does it appear?
What does enabling strictNullChecks do?
What is the difference between Omit<T, K> and Exclude<T, K>?
Implement Awaited<T> — unwrap a Promise type recursively.
What is structural typing? How does it differ from nominal typing?
What is a mapped type? Write an example.
What does as const do?
What is declaration merging?
What does ReturnType<typeof fn> evaluate to if fn is () => Promise<User[]>?
Implement a Result<T, E> type for error handling without exceptions.
What is a conditional type? Write the syntax.
What happens to TypeScript types at runtime?
What is an ambient declaration?
What is a template literal type? Give an example.
Implement Extract<T, U> using conditional types.
What is the excess property checking rule?
What does Parameters<T> return?
What is a branded type and why is it useful?
What is the satisfies operator in TypeScript?
How do you enforce exhaustive switch statements with TypeScript?
What is the difference between interface extending interface and type intersecting type?
What is covariance vs contravariance in TypeScript?
What is the difference between type narrowing with typeof vs instanceof?
Node.js
Backend31 questionsWhat are the 6 phases of the Node.js event loop in order?
What is the execution order? ```javascript setTimeout(() => console.log('A'), 0); setImmediate(() => console.log('B')); process.nextTick(() => console.log('C')); Promise.resolve().then(() => console.log('D')); ```
What is backpressure in Node.js streams?
What is the difference between process.nextTick and setImmediate?
What is the difference between cluster and worker_threads?
What are the 4 types of Node.js streams?
What is middleware in Express and what is its function signature?
Implement a rate limiter middleware using an in-memory counter.
What is prototype pollution in Node.js and how do you prevent it?
What is graceful shutdown in Node.js?
What is the difference between CommonJS require() and ESM import?
How do you prevent blocking the Node.js event loop?
What is the purpose of the Node.js cluster module?
Implement a promisify function that converts Node.js-style callbacks to Promises.
What is the SIGTERM signal and how should a Node.js app handle it?
What are the three parts of a JWT token?
What is the Node.js libuv thread pool and when is it used?
What is the difference between Fastify and Express?
How does Node.js handle concurrent connections if it's single-threaded?
What is the difference between child_process and worker_threads?
Implement a middleware that logs request duration.
What is Redis and why is it used with Node.js?
What happens when you call next(err) in Express middleware?
What is PM2 and what does it provide over running node app.js directly?
What is the buffer pool in Node.js streams and why does it matter?
Implement a simple EventEmitter from scratch in Node.js style.
What is the difference between http and https modules in Node.js?
What is SQL injection and how do you prevent it in Node.js?
How would you debug a memory leak in a Node.js production application?
What is the purpose of the 'helmet' package in Express?
What is CORS and how do you handle it in Express?
Python
Programming Languages32 questionsWhat is the output? ```python def f(x=[]): x.append(1) return x print(f()) print(f()) ```
What is the GIL and why does it matter for Python concurrency?
What does `functools.wraps` do and why is it important in decorators?
What is the difference between a generator and a list comprehension?
Implement a decorator that caches function results (memoization) without using functools.lru_cache.
What is Python's MRO (Method Resolution Order) and how does Python compute it?
What is the output? ```python x = [1, 2, 3] y = x y.append(4) print(x) ```
When would you choose asyncio over threading in Python?
What does `yield from` do in a generator?
What is the difference between `__str__` and `__repr__`?
Which method is called when you do `len(obj)`?
What is the difference between `deepcopy` and `copy`?
What is a Python Protocol and how does it differ from an abstract base class (ABC)?
What is `__slots__` and what are its tradeoffs?
Implement a context manager using `contextlib.contextmanager` that measures execution time.
What is the difference between `is` and `==` in Python?
What is the output? ```python funcs = [lambda: i for i in range(3)] print([f() for f in funcs]) ```
How does `asyncio.gather` differ from `asyncio.wait`?
What does `@property` do and when should you use it?
What is the difference between `*args` and `**kwargs`?
Explain how Python's garbage collection works.
What is the difference between a class method and a static method?
What does `if __name__ == '__main__':` do?
What is a descriptor in Python?
How would you make a class iterable?
What is the purpose of `__init_subclass__`?
True or False: Python lists are implemented as dynamic arrays.
What is `collections.OrderedDict` and is it still relevant in Python 3.7+?
What is the output? ```python a = (1, [2, 3], 4) a[1].append(5) print(a) ```
Explain Python's `super()` and when you would use it.
What are Python's built-in exceptions hierarchy top-level classes?
Arrange these in the order Python's name lookup follows them: Local → Global → Built-in → Enclosing
Git & DevOps
Software Engineering29 questionsWhat is the difference between `git merge` and `git rebase`?
What does `git reset --hard HEAD~1` do?
What is a Docker layer and how does layer caching work?
What is the difference between `git revert` and `git reset`?
What does CI/CD stand for and what is its purpose?
What is a multi-stage Docker build and why is it useful?
What is the purpose of `git stash`?
What is the difference between `git pull` and `git fetch`?
What is a Dockerfile `ENTRYPOINT` vs `CMD`?
Explain the difference between Blue-Green and Rolling deployment strategies.
What is `git bisect` and when would you use it?
What is trunk-based development?
What is `docker-compose.yml` used for?
What is a Git tag and how does it differ from a branch?
True or False: You should always use the latest tag when pulling Docker images in production.
What does `git cherry-pick` do?
What is a GitHub Actions secret and how do you use it?
What is the difference between COPY and ADD in a Dockerfile?
What is a canary deployment?
What does `git reflog` show?
What is Infrastructure as Code (IaC) and why is it important?
What is a CI/CD artifact and why should you build once, deploy many?
What is `git reset HEAD~1` without `--hard`?
What is the purpose of `.gitignore`?
What is a Docker health check and why is it important in CI/CD?
What is the difference between `git push --force` and `git push --force-with-lease`?
What is a Kubernetes readiness probe vs a liveness probe?
Arrange these Git commands in the order of a typical feature branch workflow: push, commit, checkout -b, pull request, add, merge
What is a `.dockerignore` file?
Software Design Patterns
Software Engineering15 questionsWhich SOLID principle does Factory support?
Decorator vs inheritance?
When should you NOT use Singleton?
What is CQRS?
Identify the anti-pattern: class ReportManager handles auth, data fetching, PDF generation, and email.
What is the key structural difference between Decorator and Proxy patterns?
Which scenario is the Command pattern BEST suited for?
In Clean Architecture, which layer is at the innermost core and has ZERO dependencies on outer layers?
A developer builds an OrderService that directly instantiates MySQLDatabase, SMTPEmailer, and StripePayment inside its methods. Which anti-pattern does this represent?
What is the key difference between Simple Factory and Abstract Factory?
What is the primary advantage of Software Design Patterns?
When should you NOT use Software Design Patterns?
What is the time complexity of the core operation in Software Design Patterns?
How does Software Design Patterns handle failures?
Which company popularized the use of Software Design Patterns?
Back-of-Envelope Estimation
System Design20 questionsWhat is 2^30 in human-readable form?
How many seconds are in a day (used in QPS estimation)?
An app has 100M DAU and each user makes 10 requests per day. What is the average QPS?
Peak QPS is typically what multiple of average QPS for consumer apps?
Write QPS is 1,000 and each record is 500 bytes. How much storage is generated per day?
A 3-way replicated database has 100 TB of raw data with 50 TB of indexes. What is the total disk needed?
Read QPS is 80,000 and each response is 2 KB. What is egress bandwidth?
How many app servers do you need for 50,000 peak QPS if each handles 2,000 req/s with 30% headroom?
What is the approximate throughput of a single Redis instance?
A cache stores the hot 20% of 100M objects, each 1 KB. How much RAM is needed (with 20% overhead)?
Twitter has 300M DAU, 1 tweet/user/day. What is peak write QPS? (3× peak multiplier)
Why is Uber's location write QPS dramatically higher than Twitter's tweet write QPS?
YouTube uploads 500 hours of video per minute. Roughly how many CPU cores are needed for transcoding (5 quality levels, 3× real-time encode)?
What is the latency difference between an L1 cache hit and a spinning disk seek?
What storage tier should hold data older than 1 year in a system with a 3-year retention requirement?
Your system has 10K write QPS and 200K read QPS. Which architecture decision does this directly inform?
What is the critical difference between designing for average QPS versus peak QPS?
A social graph has 500M users, each with an average of 500 connections. How many rows are in the edge table?
Why does egress bandwidth typically cost more than ingress bandwidth in cloud systems?
Uber has 5M active drivers sending GPS every 4 seconds. Which technology is most appropriate as a write buffer before the location store?
Apache Kafka
Distributed Systems20 questionsWhat is the maximum number of consumers in a consumer group that can actively consume from a topic with 6 partitions?
A producer sends a message with acks=all to a topic with replication.factor=3 and min.insync.replicas=2. Two brokers fail simultaneously. What happens?
Which Kafka configuration ensures a consumer reads only messages from committed transactions?
Explain what the ISR (In-Sync Replicas) set represents and why it matters for durability.
What happens to ordering guarantees when a Kafka producer has max.in.flight.requests.per.connection=5 and retries > 0 but enable.idempotence=false?
What is consumer group rebalancing and name two events that trigger it?
Which producer configuration is required when enable.idempotence=true?
A topic has replication.factor=3. The leader broker for a partition crashes. Under what condition can Kafka elect a new leader without data loss?
What is the role of the __consumer_offsets topic in Kafka?
Describe the difference between at-least-once, at-most-once, and exactly-once delivery semantics in Kafka.
What is a Kafka partition?
What guarantees does Kafka provide for message ordering?
What is a consumer group in Kafka?
What happens when a Kafka consumer crashes?
What is the difference between acks=0, acks=1, and acks=all?
What is Kafka's retention policy?
What is the role of ZooKeeper in Kafka?
How does Kafka achieve high throughput?
What is a dead letter queue (DLQ) in Kafka?
What is exactly-once semantics in Kafka?
AWS Cloud Services
Cloud Computing15 questionsWhich AWS feature provides automatic failover for RDS within the same region when the primary DB instance fails?
An S3 presigned URL is generated server-side. Which of the following is true about its security?
What is a Lambda cold start, and which configuration reduces it most effectively for latency-sensitive workloads?
You have a DynamoDB table with userId as partition key. You need to query orders by status across all users. What do you add?
What is the difference between a Security Group and a Network ACL (NACL) in a VPC?
Which SQS queue type guarantees exactly-once processing and strict message ordering?
What is the purpose of a NAT Gateway and where must it be placed?
In AWS IAM, what is an IAM Role and how does it differ from an IAM User?
An application processes images uploaded to S3. Which architecture is most cost-effective and scalable?
What is the purpose of a DynamoDB GSI's projection and how does it affect cost?
What is the primary advantage of AWS Cloud Services?
When should you NOT use AWS Cloud Services?
What is the time complexity of the core operation in AWS Cloud Services?
How does AWS Cloud Services handle failures?
Which company popularized the use of AWS Cloud Services?
Kubernetes & Docker
DevOps & Containers15 questionsWhat is the key difference between a Docker image and a Docker container?
In a Dockerfile, why should you COPY package.json and run npm install BEFORE copying the rest of the source code?
Which Docker networking mode allows a container to share the host machine's network stack directly, without NAT?
What is the purpose of the 'depends_on' key with 'condition: service_healthy' in Docker Compose?
Which Kubernetes control plane component is responsible for scheduling pods onto nodes?
Explain the difference between a Kubernetes Deployment's 'maxSurge' and 'maxUnavailable' rolling update parameters.
What is the difference between a ClusterIP and a NodePort Service in Kubernetes?
Why should you run container processes as a non-root user in production Dockerfiles?
What does 'kubectl rollout undo deployment/myapp' do?
What is the role of an Ingress controller in Kubernetes, and how does it differ from an Ingress resource?
What is the primary advantage of Kubernetes & Docker?
When should you NOT use Kubernetes & Docker?
What is the time complexity of the core operation in Kubernetes & Docker?
How does Kubernetes & Docker handle failures?
Which company popularized the use of Kubernetes & Docker?
JavaScript & TypeScript
Programming Languages20 questionsWhat will the following code log? ```js console.log(typeof null); ```
What is the output of: `console.log(0.1 + 0.2 === 0.3)`?
Which of the following creates a SHALLOW copy of an object?
What does the `in` operator check for in JavaScript?
In TypeScript, what does the `never` type represent?
What is the output order of this code? ```js console.log('A'); setTimeout(() => console.log('B'), 0); Promise.resolve().then(() => console.log('C')); console.log('D'); ```
What does `Array.prototype.reduce()` return when called on an empty array without an initial value?
What is the difference between `==` and `===` in JavaScript?
Which TypeScript utility type makes all properties of T optional?
What is a WeakMap and when should you use it?
What is the output of: typeof null?
What is closure in JavaScript?
What is the event loop in Node.js?
What is the difference between let, const, and var?
What does Promise.all() do?
What is the purpose of TypeScript's 'unknown' type?
What is the difference between map() and forEach()?
What is debouncing?
What does Object.freeze() do?
What is tree-shaking?
React & Next.js
Frontend15 questionsWhat is the primary purpose of the key prop when rendering lists in React?
What is a React Server Component?
Which hook should you use to run code only once when a component mounts?
What does 'use client' do in Next.js App Router?
What is the difference between useMemo and useCallback?
What does revalidatePath() do in Next.js Server Actions?
Which React hook returns a stable function reference that does not change between renders?
What is prop drilling and what are the common solutions?
What is the purpose of the loading.tsx file in the Next.js App Router?
Why is useEffect dependency array exhaustiveness important and how does ESLint help?
What is the primary advantage of React & Next.js?
When should you NOT use React & Next.js?
What is the time complexity of the core operation in React & Next.js?
How does React & Next.js handle failures?
Which company popularized the use of React & Next.js?
HTML & CSS
Frontend15 questionsWhich HTML element should you use for the primary navigation of a website?
What is the total width of an element with: width: 200px, padding: 20px, border: 5px, box-sizing: content-box?
Which property controls how flex items are distributed along the MAIN axis?
What does the alt attribute on an image do when left empty (alt='')?
Which CSS selector has the HIGHEST specificity?
What is the purpose of aria-live='polite' on an element?
Which approach correctly implements a mobile-first responsive design?
What is the minimum color contrast ratio required for normal text under WCAG 2.1 Level AA?
Which CSS property is safe to animate for smooth 60fps performance?
What does the :focus-visible pseudo-class do differently from :focus?
What is the primary advantage of HTML & CSS?
When should you NOT use HTML & CSS?
What is the time complexity of the core operation in HTML & CSS?
How does HTML & CSS handle failures?
Which company popularized the use of HTML & CSS?
Spring Boot
Programming Languages15 questionsWhich annotation combination does @SpringBootApplication replace?
Why is constructor injection preferred over field injection in Spring?
What HTTP status code should a successful POST that creates a resource return?
What is the N+1 query problem in Spring Data JPA?
What does @Transactional do when placed on a service method?
In Spring Security, where should the JWT be validated in the request lifecycle?
What is the purpose of a circuit breaker in a microservices architecture?
Which test annotation loads ONLY the web layer without a full application context?
What does @Cacheable(value = "users", key = "#id") do?
What is the difference between liveness and readiness probes in Kubernetes?
What is the primary advantage of Spring Boot?
When should you NOT use Spring Boot?
What is the time complexity of the core operation in Spring Boot?
How does Spring Boot handle failures?
Which company popularized the use of Spring Boot?
NoSQL Databases
Databases15 questionsWhich NoSQL database type is best suited for storing a social network graph where you need to traverse friend-of-friend relationships?
In the CAP theorem, which two properties does MongoDB prioritize?
What is the correct order of stages in a MongoDB aggregation pipeline to optimize performance?
In DynamoDB single-table design, what is the main reason to store multiple entity types in one table?
Which Redis command would you use to implement an atomic 'check-and-set' distributed lock?
What is the ESR rule in MongoDB compound index design?
What happens to data written to a Cassandra node during a network partition in an AP configuration?
Which embedding pattern should you use when a blog post can have millions of comments?
What is the difference between a DynamoDB GSI and LSI?
What is eventual consistency in the context of a distributed NoSQL database?
What is the primary advantage of NoSQL Databases?
When should you NOT use NoSQL Databases?
What is the time complexity of the core operation in NoSQL Databases?
How does NoSQL Databases handle failures?
Which company popularized the use of NoSQL Databases?
RDBMS & SQL
Databases15 questionsWhich JOIN type returns all rows from the left table and matched rows from the right table, filling NULLs where there is no match?
What is the difference between RANK() and DENSE_RANK() window functions when there are ties?
What type of index should you use for a column that is only ever queried with exact equality checks (e.g., WHERE user_id = 42)?
Which ACID property guarantees that a committed transaction's data survives a system crash?
At which isolation level can 'phantom reads' occur — where a transaction re-runs a query and finds new rows inserted by another committed transaction?
A table has columns: order_id (PK), customer_id, customer_name, product_id, product_name, quantity. Which normal form violation does this represent?
In PostgreSQL, what is the advantage of JSONB over the JSON data type?
A query runs slowly. EXPLAIN ANALYZE shows a Sequential Scan on a 10-million-row table for WHERE email = 'alice@example.com'. What is the best fix?
What does the LAG() window function return?
Which SQL clause filters groups AFTER aggregation, and what is the equivalent clause that filters rows BEFORE aggregation?
What is the primary advantage of RDBMS & SQL?
When should you NOT use RDBMS & SQL?
What is the time complexity of the core operation in RDBMS & SQL?
How does RDBMS & SQL handle failures?
Which company popularized the use of RDBMS & SQL?
Ready to ace your next interview?
Practice with adaptive quizzes, timed interviews, code playground, and detailed explanations — all free, no signup required.