Medium Tier Problems
Reading time: ~55 min | Interview relevance: Critical | Roles: All AI/ML Roles - MLE, AI Engineer, Data Scientist, MLOps, Data Engineer
If you could only prepare at one difficulty level, it should be medium. Medium-tier problems make up 60-70% of all interview questions at major tech companies. They are hard enough to separate prepared candidates from unprepared ones, but not so hard that they become puzzle-solving exercises disconnected from real work.
This list of 45 problems covers every category you will encounter in AI/ML interviews: coding, ML implementation, data processing, system design, and applied ML. Each problem is calibrated to be solvable in 20-35 minutes by a well-prepared candidate. If you can solve all 45 cleanly and quickly, you are ready for the vast majority of interview rounds at any company.
Category Distribution
| Category | Count | Percentage | Description |
|---|---|---|---|
| DSA & Coding | 15 | 33% | Core algorithms with ML-relevant applications |
| ML Implementation | 8 | 18% | Algorithm implementation and training concepts |
| System Design | 7 | 16% | End-to-end ML system design |
| SQL & Data | 5 | 11% | ETL, SQL, data manipulation |
| NumPy/Pandas | 5 | 11% | Data processing and analysis |
| Applied ML & Statistics | 5 | 11% | Practical ML decisions and statistical reasoning |
:::tip The Medium-Tier Mindset Medium problems test pattern recognition, not genius. For each problem, ask yourself: "What pattern does this match?" If you know 15-20 patterns cold, you can solve any medium problem. The patterns section at the end of this document lists all of them. :::
Category 1: DSA & Coding (15 Problems)
These problems combine standard algorithms with data processing and ML-relevant applications. They form the largest chunk of any coding interview.
Array & String Problems
| # | Problem | Difficulty | Time | Key Pattern | What It Tests | Company Tags | Handbook Chapter |
|---|---|---|---|---|---|---|---|
| 1 | 3Sum | Medium | 25 min | Sort + two pointers | Multi-pointer technique; duplicate handling | FAANG, All | Coding Interviews |
| 2 | Group Anagrams | Medium | 20 min | Hash map with sorted key | Canonical form mapping; grouping by equivalence class | Google, Amazon, Meta | Coding Interviews |
| 3 | Product of Array Except Self | Medium | 20 min | Prefix/suffix arrays | Building auxiliary arrays; O(1) extra space variant | FAANG, All | Coding Interviews |
| 4 | Longest Substring Without Repeating Characters | Medium | 20 min | Sliding window | Window expansion/contraction; hash set tracking | FAANG, All | Coding Interviews |
| 5 | Container With Most Water | Medium | 20 min | Two pointers | Greedy pointer movement; area optimization | FAANG, All | Coding Interviews |
| 6 | Rotate Image (Matrix Rotation) | Medium | 20 min | Transpose + reverse | In-place matrix manipulation; layer-by-layer rotation | Amazon, Google, Microsoft | Coding Interviews |
| 7 | Spiral Matrix Traversal | Medium | 25 min | Boundary tracking | Direction state machine; boundary shrinking | Amazon, Google, Bloomberg | Coding Interviews |
Tree & Graph Problems
| # | Problem | Difficulty | Time | Key Pattern | What It Tests | Company Tags | Handbook Chapter |
|---|---|---|---|---|---|---|---|
| 8 | LRU Cache | Medium | 30 min | Hash map + doubly-linked list | O(1) get/put with eviction; foundational for caching systems | FAANG, All | Coding Interviews |
| 9 | Number of Islands | Medium | 20 min | BFS/DFS flood fill | Connected components; grid traversal | FAANG, All | Coding Interviews |
| 10 | Course Schedule (Topological Sort) | Medium | 25 min | DFS cycle detection + topo sort | DAG processing; dependency resolution for pipeline ordering | Google, Meta, Amazon | Coding Interviews |
| 11 | Binary Tree Level Order Traversal | Medium | 20 min | BFS with level tracking | Queue-based traversal; level-aware processing | All | Coding Interviews |
Advanced Patterns
| # | Problem | Difficulty | Time | Key Pattern | What It Tests | Company Tags | Handbook Chapter |
|---|---|---|---|---|---|---|---|
| 12 | Meeting Rooms II | Medium | 25 min | Sweep line / min-heap | Resource scheduling; GPU allocation; training job scheduling | Google, Meta, Uber | Coding Interviews |
| 13 | Coin Change | Medium | 25 min | Bottom-up DP | Optimal substructure; tabulation vs. memoization | FAANG, All | Coding Interviews |
| 14 | Implement a Rate Limiter (Leaky Bucket) | Medium | 25 min | Queue-based rate limiting | API rate limiting for model serving endpoints | Uber, Airbnb, Stripe | ML System Design |
| 15 | Top K Frequent Elements | Medium | 20 min | Heap / bucket sort | Priority queues; frequency analysis for feature selection | Amazon, Google, Meta | Coding Interviews |
:::warning DSA Coding Red Flags
- Jumping to code without discussing approach first
- Not considering edge cases (empty input, single element, overflow)
- Writing O(n^2) when O(n) or O(n log n) is expected
- Cannot analyze time and space complexity of your solution
- Ignoring the interviewer's hints (they are trying to help) :::
Category 2: ML Implementation (8 Problems)
These problems test whether you understand ML algorithms deeply enough to implement them, not just call sklearn. Interviewers want to see you write the math in code.
Algorithm Implementation
| # | Problem | Difficulty | Time | Key Pattern | What It Tests | Company Tags | Handbook Chapter |
|---|---|---|---|---|---|---|---|
| 16 | Implement Batch Gradient Descent with Mini-Batches | Medium | 30 min | Data batching + gradient accumulation | Core training loop; batch vs. stochastic tradeoffs | FAANG, AI Labs | ML Fundamentals |
| 17 | Implement TF-IDF from Scratch | Medium | 25 min | Term frequency + inverse document frequency | Text feature engineering; information retrieval basics | Google, Amazon | ML Fundamentals |
| 18 | Implement AUC-ROC Computation | Medium | 25 min | Sorting + threshold sweep | Ranking metrics; threshold-independent evaluation | Meta, Uber, Airbnb | ML Fundamentals |
| 19 | Implement Stratified K-Fold Cross-Validation | Medium | 25 min | Balanced splitting | Class balance preservation; evaluation rigor | Google, Meta | ML Fundamentals |
Training & Evaluation
| # | Problem | Difficulty | Time | Key Pattern | What It Tests | Company Tags | Handbook Chapter |
|---|---|---|---|---|---|---|---|
| 20 | Implement Decision Tree (ID3/CART) for Classification | Medium | 35 min | Recursive partitioning + information gain | Tree building, feature selection, stopping criteria | Google, Amazon, Big Tech | ML Fundamentals |
| 21 | Implement a Streaming Mean and Variance Calculator | Medium | 20 min | Welford's algorithm | Online computation; numerical stability | Google, Uber, Databricks | ML Fundamentals |
| 22 | Implement Reservoir Sampling | Medium | 20 min | Probabilistic sampling | Sampling from streams; uniform probability guarantee | Google, Meta | ML Fundamentals |
| 23 | Implement Learning Rate Scheduling (Step Decay + Cosine Annealing) | Medium | 25 min | Schedule functions | Training stability and convergence speed | Google, Meta, AI Labs | Deep Learning |
:::tip ML Implementation Strategy When implementing ML algorithms in interviews:
- Start with the mathematical formulation (write it down)
- Identify the core operation (dot product, distance, gradient)
- Use NumPy vectorization (never loop over data points)
- Handle edge cases (empty data, single class, numerical overflow)
- Discuss complexity (training time, inference time, space) :::
Category 3: System Design (7 Problems)
Medium-tier system design problems focus on well-scoped ML systems. You should be able to cover end-to-end architecture in 35-40 minutes.
| # | Problem | Difficulty | Time | Key Pattern | What It Tests | Company Tags | Handbook Chapter |
|---|---|---|---|---|---|---|---|
| 24 | Design a Product Recommendation System for E-Commerce | Medium | 40 min | Collaborative filtering + content-based | The canonical MLE system design problem | Amazon, Meta, Pinterest | ML System Design |
| 25 | Design a Spam Detection System | Medium | 35 min | Text classification + feedback loops | Content safety with adversarial robustness | Google, Meta, Microsoft | ML System Design |
| 26 | Design a Credit Risk Scoring System | Medium | 35 min | Feature engineering + explainability | Regulated ML with fairness constraints | Stripe, Square, Goldman | ML System Design |
| 27 | Design an Anomaly Detection System for Cloud Infrastructure | Medium | 35 min | Time-series models + alerting | Infrastructure monitoring with ML | Google, Amazon, Datadog | ML System Design |
| 28 | Design a Model A/B Testing Framework | Medium | 35 min | Traffic splitting, statistical tests | Rigorous model deployment and evaluation | FAANG, Big Tech | ML System Design |
| 29 | Design a Feature Pipeline with Online and Offline Serving | Medium | 35 min | Feature computation, consistency | Feature store design; online/offline consistency | Uber, Airbnb, Databricks | ML System Design |
| 30 | Design a Document Classification Pipeline | Medium | 35 min | NLP preprocessing + embeddings | End-to-end NLP system with serving | Google, Amazon | ML System Design |
:::note System Design Framework for Medium Problems Use this structure for every medium system design answer:
- Clarify requirements (2 min): Users, scale, latency, freshness
- High-level architecture (5 min): Draw the boxes and arrows
- Data pipeline (8 min): How data flows from raw to features
- Model architecture (8 min): Why this model for this problem
- Serving (7 min): How predictions reach users
- Monitoring (5 min): What can go wrong and how you detect it
- Follow-ups (5 min): Scaling, improvements, edge cases :::
Category 4: SQL & Data (5 Problems)
SQL and data manipulation problems that appear in every data-adjacent role. Window functions are the most critical skill.
| # | Problem | Difficulty | Time | Key Pattern | What It Tests | Company Tags | Handbook Chapter |
|---|---|---|---|---|---|---|---|
| 31 | Find the Nth Highest Salary per Department | Medium | 20 min | Window functions (DENSE_RANK) | Ranking within groups; window function fluency | Google, Amazon, Meta | Coding Interviews |
| 32 | Compute Retention Cohorts | Medium | 25 min | Self-join, date arithmetic | Product analytics; user lifecycle analysis | Meta, Spotify, Pinterest | Coding Interviews |
| 33 | Sessionize Clickstream Data | Medium | 30 min | LAG + cumulative SUM | User behavior analysis; the canonical DE SQL problem | Google, Meta, Airbnb | Coding Interviews |
| 34 | Write an Idempotent MERGE (Upsert) Statement | Medium | 20 min | MERGE / INSERT ON CONFLICT | Pipeline reruns must not duplicate data | All | Coding Interviews |
| 35 | Compute a Funnel Analysis Across Multiple Steps | Medium | 25 min | CASE WHEN + window functions | Product analytics; conversion tracking | Meta, Airbnb, Uber | Coding Interviews |
Category 5: NumPy/Pandas (5 Problems)
Data processing problems using Python's core data stack. These appear in almost every MLE and DS interview.
| # | Problem | Difficulty | Time | Key Pattern | What It Tests | Company Tags | Handbook Chapter |
|---|---|---|---|---|---|---|---|
| 36 | Implement a Schema Validator for Incoming JSON Data | Medium | 25 min | Schema validation, error handling | Data quality at ingestion; defensive programming | Airbnb, Stripe | Coding Interviews |
| 37 | Build an Incremental Data Loader with Watermarks | Medium | 30 min | Change tracking, watermark logic | Incremental processing reduces cost and latency | FAANG, Databricks | Coding Interviews |
| 38 | Flatten Deeply Nested JSON to Tabular Format | Medium | 25 min | Recursive parsing | Semi-structured data handling; schema inference | Airbnb, Snowflake | Coding Interviews |
| 39 | Build a Data Deduplication Pipeline | Medium | 25 min | Hashing, window-based dedup | Exact and near-duplicate detection | Meta, Airbnb, Uber | Coding Interviews |
| 40 | Compute Rolling Statistics with GroupBy | Medium | 20 min | Pandas rolling + groupby | Time-series feature engineering; window aggregation | All | ML Fundamentals |
Category 6: Applied ML & Statistics (5 Problems)
These problems test practical ML decision-making and statistical reasoning. There is no code to write --- just structured thinking and clear communication.
| # | Problem | Difficulty | Time | Key Pattern | What It Tests | Company Tags | Handbook Chapter |
|---|---|---|---|---|---|---|---|
| 41 | Debug a Model That Is Not Converging | Medium | 25 min | Systematic debugging | Data, model, optimization checklist approach | FAANG, All | ML Fundamentals |
| 42 | Detect and Mitigate Data Leakage | Medium | 25 min | Temporal, feature leakage | The #1 cause of offline-online metric gaps | All | ML Fundamentals |
| 43 | Compare Online vs. Offline Metrics Discrepancy | Medium | 25 min | Distribution shift, delayed feedback | The classic MLE debugging scenario | Meta, Google, Uber | ML Fundamentals |
| 44 | Design a Model Retraining Strategy | Medium | 25 min | Trigger-based vs. scheduled | Model decay detection and automated retraining | FAANG, Big Tech | ML System Design |
| 45 | Explain Random Forest vs. Gradient Boosting: When to Use Each | Medium | 20 min | Ensemble comparison | Practical model selection for tabular data | All | ML Fundamentals |
Problem Deep Dives
Each deep dive gives you the full solution approach, code template, and interviewer expectations so you can practice realistically.
Problem 1: 3Sum
Why this problem matters: 3Sum is the gateway to the two-pointer pattern. Once you master it, you can solve 4Sum, 3Sum Closest, and a family of related problems. It also tests your ability to handle duplicate elements cleanly.
Approach:
1. Sort the array
2. Fix one element (i), use two pointers (lo, hi) on the rest
3. Skip duplicates at every level to avoid duplicate triplets
4. Time: O(n^2), Space: O(1) excluding output
Code Template:
def three_sum(nums):
nums.sort()
result = []
for i in range(len(nums) - 2):
if i > 0 and nums[i] == nums[i - 1]:
continue # skip duplicate anchor
lo, hi = i + 1, len(nums) - 1
while lo < hi:
total = nums[i] + nums[lo] + nums[hi]
if total < 0:
lo += 1
elif total > 0:
hi -= 1
else:
result.append([nums[i], nums[lo], nums[hi]])
while lo < hi and nums[lo] == nums[lo + 1]:
lo += 1 # skip duplicates
while lo < hi and nums[hi] == nums[hi - 1]:
hi -= 1 # skip duplicates
lo += 1
hi -= 1
return result
Key Points Interviewers Check:
- Sorting as a prerequisite for two pointers
- Duplicate skipping at both the outer loop and inner pointers
- Correct termination conditions
- Can you extend to k-Sum? (Recursive generalization)
Problem 8: LRU Cache
Why this problem matters: LRU Cache is the #1 most-asked medium design problem. It tests whether you can combine two data structures to achieve O(1) operations, and it is directly applicable to feature caching, model result caching, and embedding lookup caching in ML systems.
Data Structure:
Hash Map: key -> Node pointer (O(1) lookup)
Doubly-Linked List: maintains access order (O(1) move/remove)
Operations:
class Node:
def __init__(self, key, val):
self.key = key
self.val = val
self.prev = None
self.next = None
class LRUCache:
def __init__(self, capacity):
self.capacity = capacity
self.cache = {} # key -> Node
self.head = Node(0, 0) # dummy head
self.tail = Node(0, 0) # dummy tail
self.head.next = self.tail
self.tail.prev = self.head
def get(self, key):
if key in self.cache:
node = self.cache[key]
self._remove(node)
self._add(node) # move to front
return node.val
return -1
def put(self, key, value):
if key in self.cache:
self._remove(self.cache[key])
node = Node(key, value)
self._add(node)
self.cache[key] = node
if len(self.cache) > self.capacity:
lru = self.head.next
self._remove(lru)
del self.cache[lru.key]
def _add(self, node):
# Add before tail (most recent)
prev = self.tail.prev
prev.next = node
node.prev = prev
node.next = self.tail
self.tail.prev = node
def _remove(self, node):
prev = node.prev
nxt = node.next
prev.next = nxt
nxt.prev = prev
Key Points Interviewers Check:
- O(1) for both get and put operations
- Correct eviction of the least recently used item
- Handling of duplicate keys (update, not duplicate)
- Thread safety discussion for production use
ML Relevance: Feature stores cache frequently accessed features. Model serving caches recent predictions. Embedding lookup tables use LRU eviction. If you can explain the ML connection, you stand out.
Problem 16: Implement Batch Gradient Descent with Mini-Batches
Why this problem matters: Every neural network trains with mini-batch gradient descent. Interviewers want to see that you understand the mechanics beyond calling model.fit().
Code Template:
import numpy as np
def mini_batch_gradient_descent(X, y, lr=0.01, batch_size=32, epochs=100):
n_samples, n_features = X.shape
weights = np.zeros(n_features)
bias = 0.0
for epoch in range(epochs):
# Shuffle data each epoch
indices = np.random.permutation(n_samples)
X_shuffled = X[indices]
y_shuffled = y[indices]
for start in range(0, n_samples, batch_size):
end = min(start + batch_size, n_samples)
X_batch = X_shuffled[start:end]
y_batch = y_shuffled[start:end]
# Forward pass
predictions = X_batch @ weights + bias
# Compute gradients
error = predictions - y_batch
grad_w = (2 / len(y_batch)) * (X_batch.T @ error)
grad_b = (2 / len(y_batch)) * np.sum(error)
# Update
weights -= lr * grad_w
bias -= lr * grad_b
return weights, bias
Key Points Interviewers Check:
- Shuffle data each epoch (not just once)
- Correct gradient computation (vectorized, not looped)
- Batch size handling for the last (potentially smaller) batch
- Numerical stability discussion (gradient clipping, learning rate warmup)
- Can you extend to momentum, Adam, or weight decay?
Problem 20: Implement Decision Tree (ID3/CART)
Why this problem matters: Decision trees are the foundation of gradient boosting (XGBoost, LightGBM), the most dominant algorithm for tabular data in industry. Implementing one from scratch proves you understand feature selection, splitting criteria, and recursive structure.
Code Template:
import numpy as np
def entropy(y):
counts = np.bincount(y)
probs = counts[counts > 0] / len(y)
return -np.sum(probs * np.log2(probs))
def information_gain(y, mask):
parent = entropy(y)
n = len(y)
left, right = y[mask], y[~mask]
if len(left) == 0 or len(right) == 0:
return 0
child = (len(left) / n) * entropy(left) + (len(right) / n) * entropy(right)
return parent - child
def best_split(X, y):
best_gain = 0
best_feature, best_threshold = None, None
for feature in range(X.shape[1]):
thresholds = np.unique(X[:, feature])
for threshold in thresholds:
mask = X[:, feature] <= threshold
gain = information_gain(y, mask)
if gain > best_gain:
best_gain = gain
best_feature = feature
best_threshold = threshold
return best_feature, best_threshold
def build_tree(X, y, depth=0, max_depth=5):
if len(np.unique(y)) == 1 or depth >= max_depth:
return {'leaf': True, 'prediction': np.bincount(y).argmax()}
feature, threshold = best_split(X, y)
if feature is None:
return {'leaf': True, 'prediction': np.bincount(y).argmax()}
mask = X[:, feature] <= threshold
return {
'leaf': False,
'feature': feature,
'threshold': threshold,
'left': build_tree(X[mask], y[mask], depth + 1, max_depth),
'right': build_tree(X[~mask], y[~mask], depth + 1, max_depth),
}
Key Points Interviewers Check:
- Correct entropy/Gini computation
- Efficient threshold selection (sort once, scan)
- Stopping criteria (max depth, min samples, pure node)
- Can you extend to regression? (Variance reduction instead of information gain)
Problem 33: Sessionize Clickstream Data
Why this problem matters: This is the most commonly asked SQL problem for any data-adjacent role. It combines window functions, conditional logic, and the cumulative sum trick.
Solution:
WITH time_gaps AS (
SELECT
user_id,
event_time,
event_time - LAG(event_time) OVER (
PARTITION BY user_id ORDER BY event_time
) AS gap
FROM events
),
session_flags AS (
SELECT
*,
CASE
WHEN gap IS NULL OR gap > INTERVAL '30 minutes' THEN 1
ELSE 0
END AS new_session
FROM time_gaps
)
SELECT
user_id,
event_time,
SUM(new_session) OVER (
PARTITION BY user_id ORDER BY event_time
) AS session_id
FROM session_flags;
The Cumulative Sum Trick: Flag every session boundary with 1, then take a running SUM. Each session gets a unique incrementing ID. This pattern applies to any "group consecutive events" problem.
Key Points Interviewers Check:
- Correct use of LAG with PARTITION BY and ORDER BY
- Handling NULL for the first event (no previous event to compare)
- Configurable session timeout (not hardcoded)
- Can you extend to compute session duration and session-level aggregates?
Problem 41: Debug a Model That Is Not Converging
Why this problem matters: Every ML engineer has faced a model that refuses to converge. Interviewers test whether you have a systematic debugging approach or just guess randomly.
Structured Debugging Checklist:
| Step | Check | What to Look For |
|---|---|---|
| 1 | Data | Are labels correct? Is there class imbalance? Are features normalized? |
| 2 | Loss function | Does the loss match the problem type? Is it numerically stable? |
| 3 | Learning rate | Too high (oscillating)? Too low (flat)? Try LR finder. |
| 4 | Gradient flow | Are gradients vanishing or exploding? Check gradient norms per layer. |
| 5 | Architecture | Is the model capacity sufficient? Too small underfits, too large memorizes noise. |
| 6 | Initialization | Are weights initialized correctly for this activation function? |
| 7 | Overfit one batch | Can the model memorize 1 batch perfectly? If not, there is a bug. |
| 8 | Data pipeline | Are inputs and labels aligned after shuffling? Is preprocessing applied correctly? |
The One-Batch Test: Before debugging anything else, try to overfit a single batch of 8-16 examples. If the model cannot drive loss to near zero on a tiny batch, the problem is in the model or training code, not in the data. This single test eliminates half of all debugging directions.
5-Week Medium Tier Study Plan
| Week | Focus | Problems | Daily Load |
|---|---|---|---|
| Week 1 | DSA coding | #1-15 (all coding problems) | 2-3 problems/day |
| Week 2 | ML implementation | #16-23 (ML coding) | 1-2 problems/day |
| Week 3 | System design + SQL | #24-35 (design + data) | 1-2 problems/day |
| Week 4 | NumPy/Pandas + Applied ML | #36-45 (data processing + applied) | 1-2 problems/day |
| Week 5 | Integration + mocks | Revisit weak areas + full mocks | 1 problem + mocks |
Week 1: DSA Coding
Day 1: #1, #2 (3Sum, Group Anagrams - sorting and hashing patterns)
Day 2: #3, #4 (Product Except Self, Longest Substring - prefix and sliding window)
Day 3: #5, #6, #7 (Container With Most Water, Rotate Image, Spiral Matrix)
Day 4: #8 (LRU Cache - spend extra time, this is critical)
Day 5: #9, #10 (Islands, Course Schedule - graph fundamentals)
Day 6: #11, #12 (Level order, Meeting Rooms II - BFS and intervals)
Day 7: #13, #14, #15 (Coin Change, Rate Limiter, Top K)
Week 2: ML Implementation
Day 1: #16 (Mini-batch gradient descent - take your time, understand every line)
Day 2: #17, #18 (TF-IDF, AUC-ROC - text features and evaluation)
Day 3: #19, #20 (Stratified K-Fold, Decision Tree - evaluation and trees)
Day 4: #21, #22 (Welford's algorithm, Reservoir Sampling - online algorithms)
Day 5: #23 (Learning rate scheduling - training optimization)
Day 6: Review all ML problems; re-solve weak ones from scratch
Day 7: Timed practice - pick 3 random ML problems, solve each in 25 minutes
Week 3: System Design + SQL
Day 1: #24 (Product recommendations - the canonical system design problem)
Day 2: #25, #26 (Spam detection, credit risk - classification systems)
Day 3: #27, #28 (Anomaly detection, A/B testing - monitoring and experimentation)
Day 4: #29, #30 (Feature pipeline, document classification)
Day 5: #31, #32 (Nth salary, retention cohorts - window functions)
Day 6: #33, #34, #35 (Sessionization, MERGE, funnel analysis)
Day 7: Review all designs; practice explaining out loud with a timer
Week 4: NumPy/Pandas + Applied ML
Day 1: #36, #37 (Schema validation, incremental loader)
Day 2: #38, #39 (Nested JSON, deduplication)
Day 3: #40 (Rolling statistics with GroupBy)
Day 4: #41, #42 (Debug non-convergence, data leakage)
Day 5: #43, #44 (Online/offline gap, retraining strategy)
Day 6: #45 (RF vs GBT comparison)
Day 7: Review and re-solve weak problems from all categories
Week 5: Integration + Mocks
Day 1: Full mock - coding (25 min) + ML implementation (25 min)
Day 2: Full mock - system design (40 min) + SQL (20 min)
Day 3: Full mock - applied ML discussion (30 min) + coding (25 min)
Day 4: Targeted review of any problems you could not solve cleanly
Day 5: Full mock - complete interview loop simulation (3 hours)
Day 6: Full mock - complete interview loop simulation (3 hours)
Day 7: Final review of all weak areas; light practice only
:::note Mock Interview Protocol For realistic mock practice:
- Use a timer visible on your screen
- Explain your approach out loud before coding (even when alone)
- Write code in a plain text editor (no autocomplete)
- After finishing, review your solution as if you were the interviewer
- Track your solve rate and time per problem in a spreadsheet :::
Medium-Tier Patterns Cheat Sheet
Master these 20 patterns and you can solve any medium problem:
| # | Pattern | Problems | Recognition Signal |
|---|---|---|---|
| 1 | Two Pointers (sorted) | #1, #5 | Sorted input, find pair/triplet with sum |
| 2 | Sliding Window | #4 | Contiguous subarray/substring with constraint |
| 3 | Hash Map Grouping | #2, #8 | Group items by equivalence class |
| 4 | Prefix/Suffix | #3 | Need left and right context for each element |
| 5 | Matrix Manipulation | #6, #7 | In-place 2D transformations |
| 6 | BFS/DFS Grid | #9 | Connected components in 2D grid |
| 7 | Topological Sort | #10 | Dependencies, prerequisites, ordering |
| 8 | Level-order BFS | #11 | Process tree level by level |
| 9 | Interval Processing | #12 | Overlapping intervals, scheduling |
| 10 | Bottom-up DP | #13 | Optimal value with overlapping subproblems |
| 11 | Heap / Priority Queue | #15 | Top-K, streaming max/min |
| 12 | Window Functions (SQL) | #31, #32, #33, #35 | Ranking, running totals, LAG/LEAD |
| 13 | Gradient Computation | #16, #23 | Training loop, optimization |
| 14 | Threshold Sweep | #18 | AUC, precision-recall curves |
| 15 | Recursive Partitioning | #20 | Decision trees, divide-and-conquer |
| 16 | Online Algorithms | #21, #22 | Streaming computation, bounded memory |
| 17 | Multi-stage Pipeline | #24, #25 | Retrieval -> ranking -> reranking |
| 18 | Feature Store Design | #29 | Online/offline consistency |
| 19 | A/B Test Design | #28, #35 | Hypothesis, metrics, sample size |
| 20 | Debug Checklist | #41, #42, #43 | Systematic elimination of failure modes |
Common Mistakes by Category
Knowing what goes wrong is as important as knowing the right answer.
Coding Mistakes
| Mistake | Why It Happens | How to Fix |
|---|---|---|
| Off-by-one in binary search | Unclear on inclusive/exclusive bounds | Always write lo, hi = 0, len(arr) - 1 and use while lo <= hi |
| Modifying input while iterating | Not creating a copy | Use index-based iteration or build new output |
| Not handling empty input | Assumption that input has at least 1 element | Add explicit check at the start |
| Forgetting to skip duplicates | Not thinking about output uniqueness | Add duplicate-skipping logic after every valid result |
ML Implementation Mistakes
| Mistake | Why It Happens | How to Fix |
|---|---|---|
| Using for-loops over data points | Not thinking in vectors | Rewrite with matrix operations: X.T @ error not for x in X |
| Wrong gradient sign | Confusion between minimize and maximize | Derive gradient on paper first, verify with finite differences |
| Not shuffling data | Forgetting that order matters | Shuffle indices at the start of each epoch |
| Ignoring numerical stability | Not thinking about log(0) or exp(large) | Use np.clip, logsumexp, add epsilon to denominators |
System Design Mistakes
| Mistake | Why It Happens | How to Fix |
|---|---|---|
| No monitoring plan | Focusing only on building, not operating | Always end with "what can go wrong and how do we detect it" |
| Ignoring data pipeline | Jumping straight to model architecture | Spend 30% of your time on data: collection, cleaning, features |
| Not discussing tradeoffs | Presenting one approach as the only option | For every choice, explain what you considered and why you chose this |
| Skipping latency requirements | Not thinking about serving constraints | State latency budget upfront and design backwards from it |
SQL Mistakes
| Mistake | Why It Happens | How to Fix |
|---|---|---|
| GROUP BY errors | Selecting non-aggregated columns | Every non-aggregated column must be in GROUP BY |
| Window function confusion | Mixing up PARTITION BY and GROUP BY | PARTITION BY does not reduce rows; GROUP BY does |
| Self-join pitfalls | Cartesian explosion on large tables | Always check join conditions produce expected row count |
| NULL handling | Forgetting that NULL != NULL | Use IS NULL / IS NOT NULL; COALESCE for defaults |
Difficulty Calibration Guide
How to know if you are solving medium problems at interview pace:
| Metric | Below Par | On Track | Interview Ready |
|---|---|---|---|
| Solve time (coding) | >35 min | 20-30 min | <20 min |
| Solve time (ML implementation) | >30 min | 20-25 min | <20 min |
| Solve time (SQL) | >25 min | 15-20 min | <15 min |
| System design coverage | Miss 2+ components | Cover all components | Deep dive on 1-2 |
| Bug-free rate | <50% | 70-80% | >85% |
| Can explain complexity | Rarely | Usually | Always |
:::danger Signs You Need More Easy Practice First
- You cannot solve #1 (3Sum) in under 30 minutes
- You do not know what a window function is before attempting SQL problems
- You cannot implement gradient descent from the math
- You do not understand BFS vs. DFS conceptually
If any of these apply, spend a week on the Easy Tier first. Building on shaky fundamentals wastes time. :::
Time Allocation Strategy
Not all categories deserve equal time. Prioritize based on your target role:
| Role | DSA | ML Impl | System Design | SQL/Data | Applied ML |
|---|---|---|---|---|---|
| MLE | 30% | 25% | 25% | 10% | 10% |
| AI Engineer | 25% | 30% | 20% | 10% | 15% |
| Data Scientist | 15% | 20% | 15% | 30% | 20% |
| MLOps Engineer | 20% | 10% | 35% | 20% | 15% |
| Data Engineer | 25% | 5% | 25% | 35% | 10% |
Scoring Rubric
Use this rubric to self-assess after each practice problem:
| Score | Criteria | What It Means |
|---|---|---|
| 5 - Perfect | Solved in under target time, bug-free, discussed complexity and tradeoffs | You are interview ready for this problem type |
| 4 - Strong | Solved in target time with minor bugs, caught them during review | Nearly ready, practice for speed |
| 3 - Adequate | Solved with hints or slightly over time, correct final answer | Need more practice with this pattern |
| 2 - Weak | Needed significant hints, major bugs, over time | Study the pattern, re-solve from scratch tomorrow |
| 1 - Did not solve | Could not reach a working solution | Foundational gap - review the underlying concept first |
Track your scores over time. Your goal is to score 4 or 5 on every problem in this list before your interview.
Next Steps
After completing the Medium Tier:
- Hard Tier for Staff+ roles and top-tier companies
- Google-Style Problems if targeting Google (emphasis on scalability and multiple approaches)
- Meta-Style Problems if targeting Meta (emphasis on product ML and speed)
- Startup-Style Problems if targeting startups (emphasis on end-to-end thinking and practicality)
- Role-specific lists in the Role-Specific Prep section for deeper preparation in your target role
