---
title: Comprehensive Guide to the Top 30 Essential LeetCode Problems for Technical Interview Preparation Across Leading Tech Companies
created: 2026-03-03
updated: 2026-03-03
type: summary
tags: ["algorithms", "interview", "leetcode", "notes", "telegram"]
external: http://go/ui/posts/2106/
status: inbox
---

# 🏆 Top 30 Must-Know LeetCode Questions for Interviews

Based on real-world frequency data from major tech companies (FAANG, Microsoft, Bloomberg, etc.), here are the **most tested and most popular** problems, ordered by overall interview frequency.

---

## 🥇 Tier 1: Absolute Must-Know (Top 10)

### 1. **Two Sum** (LeetCode #1)
- **Difficulty:** Easy
- **What it tests:** Hash Maps, Array traversal
- **Companies:** Virtually every company
- **💡 Tips:**
  - Use a hash map to store `{value: index}` as you iterate
  - One-pass solution: check if `target - nums[i]` exists in the map *before* inserting
  - Time: O(n), Space: O(n)
  - 🚫 Don't sort — you'll lose original indices

---

### 2. **Best Time to Buy and Sell Stock** (LeetCode #121)
- **Difficulty:** Easy
- **What it tests:** Greedy, Sliding Window / Kadane's variant
- **Companies:** Amazon, Facebook, Goldman Sachs, Microsoft
- **💡 Tips:**
  - Track `minPrice` so far, compute `profit = price - minPrice` at each step
  - Update max profit as you go — single pass O(n)
  - This is essentially Kadane's algorithm on price differences

---

### 3. **Valid Parentheses** (LeetCode #20)
- **Difficulty:** Easy
- **What it tests:** Stack
- **Companies:** Amazon, Bloomberg, Facebook, Google
- **💡 Tips:**
  - Push opening brackets onto stack; pop when you see a closing bracket
  - Check that the popped bracket matches the expected pair
  - At the end, stack must be empty
  - Use a hash map for bracket pair matching: `{ ')':'(', ']':'[', '}':'{' }`

---

### 4. **Merge Two Sorted Lists** (LeetCode #21)
- **Difficulty:** Easy
- **What it tests:** Linked Lists, Recursion, Two Pointers
- **Companies:** Amazon, Apple, Microsoft, Adobe
- **💡 Tips:**
  - Use a `dummy` head node to simplify edge cases
  - Iterative: compare heads, attach smaller, advance pointer
  - Don't forget to attach the remaining non-empty list at the end

---

### 5. **Valid Anagram** (LeetCode #242)
- **Difficulty:** Easy
- **What it tests:** Hash Map / Sorting, String manipulation
- **Companies:** Amazon, Bloomberg, Microsoft, Spotify
- **💡 Tips:**
  - Method 1: Sort both strings, compare → O(n log n)
  - Method 2: Frequency count with array/hashmap → O(n)
  - Follow-up: What if inputs contain Unicode? → Use a hash map instead of a fixed array

---

### 6. **Maximum Subarray** (LeetCode #53)
- **Difficulty:** Medium
- **What it tests:** Kadane's Algorithm, Dynamic Programming
- **Companies:** Amazon, Apple, Google, LinkedIn, Microsoft
- **💡 Tips:**
  - Kadane's: `currentSum = max(nums[i], currentSum + nums[i])`
  - Track `maxSum` globally
  - Key insight: if `currentSum` becomes negative, reset it — a negative prefix can never help
  - Follow-up: Divide and conquer approach is O(n log n)

---

### 7. **Merge Intervals** (LeetCode #56)
- **Difficulty:** Medium
- **What it tests:** Sorting, Interval problems, Greedy
- **Companies:** Google, Facebook, Amazon, Bloomberg, Twitter
- **💡 Tips:**
  - Sort by start time first
  - Compare current interval's start with previous interval's end
  - If overlapping: merge by extending end = max(end, current.end)
  - Very common building block — master this pattern!

---

### 8. **3Sum** (LeetCode #15)
- **Difficulty:** Medium
- **What it tests:** Two Pointers, Sorting, Deduplication
- **Companies:** Facebook, Amazon, Apple, Google, Microsoft
- **💡 Tips:**
  - Sort the array first
  - Fix one number, use two-pointer on the rest
  - **Critical:** Skip duplicates at all three levels to avoid duplicate triplets
  - Time: O(n²), Space: O(1) excluding output

---

### 9. **Group Anagrams** (LeetCode #49)
- **Difficulty:** Medium
- **What it tests:** Hash Maps, String manipulation, Sorting
- **Companies:** Amazon, Facebook, Google, Microsoft
- **💡 Tips:**
  - Key idea: anagrams have the same sorted string
  - Use `sorted(word)` as hash map key → group words together
  - Alternative key: tuple of 26 character counts (avoids sort cost per word)

---

### 10. **LRU Cache** (LeetCode #146)
- **Difficulty:** Medium
- **What it tests:** Hash Map + Doubly Linked List, Design
- **Companies:** Amazon, Google, Facebook, Microsoft, Bloomberg
- **💡 Tips:**
  - Hash map for O(1) lookup; doubly linked list for O(1) insert/remove
  - On `get`: move node to head (most recently used)
  - On `put`: if full, evict the tail node (least recently used)
  - Use dummy `head` and `tail` sentinel nodes to avoid null checks
  - In Python, `OrderedDict` is a shortcut but interviewers usually want the manual implementation

---

## 🥈 Tier 2: Extremely High Frequency (11–20)

### 11. **Longest Substring Without Repeating Characters** (LeetCode #3)
- **Difficulty:** Medium
- **What it tests:** Sliding Window, Hash Set/Map
- **Companies:** Amazon, Bloomberg, Facebook, Google
- **💡 Tips:**
  - Sliding window with a set tracking characters in the current window
  - When a duplicate is found, shrink window from the left
  - Optimization: use a map storing last index of each char to jump the left pointer directly

---

### 12. **Product of Array Except Self** (LeetCode #238)
- **Difficulty:** Medium
- **What it tests:** Prefix/Suffix products, Array
- **Companies:** Amazon, Apple, Facebook, Microsoft
- **💡 Tips:**
  - Build `left[]` prefix products and `right[]` suffix products
  - `result[i] = left[i] * right[i]`
  - O(1) extra space trick: use output array for left pass, then single variable for right pass
  - **Constraint:** No division allowed!

---

### 13. **Contains Duplicate** (LeetCode #217)
- **Difficulty:** Easy
- **What it tests:** Hash Set
- **Companies:** Amazon, Apple, Adobe
- **💡 Tips:**
  - Insert each element into a set; if already present → return true
  - One-liner: `len(nums) != len(set(nums))`
  - Simple but often a warm-up problem

---

### 14. **Reverse Linked List** (LeetCode #206)
- **Difficulty:** Easy
- **What it tests:** Linked List, Pointers, Recursion
- **Companies:** Amazon, Apple, Bloomberg, Microsoft
- **💡 Tips:**
  - Iterative: maintain `prev`, `curr`, `next` pointers
  - Recursive: reverse the rest, then point `curr.next.next = curr`, `curr.next = null`
  - Be ready to do both iterative AND recursive

---

### 15. **Binary Tree Level Order Traversal** (LeetCode #102)
- **Difficulty:** Medium
- **What it tests:** BFS, Queue, Trees
- **Companies:** Amazon, Facebook, Microsoft, Bloomberg
- **💡 Tips:**
  - Classic BFS using a queue
  - Process nodes level by level: record queue size at each level
  - Variations: zigzag, bottom-up, right side view — all build on this

---

### 16. **Climbing Stairs** (LeetCode #70)
- **Difficulty:** Easy
- **What it tests:** Dynamic Programming (Fibonacci pattern)
- **Companies:** Amazon, Apple, Adobe, Google
- **💡 Tips:**
  - `dp[i] = dp[i-1] + dp[i-2]` — it's literally Fibonacci!
  - Optimize space to O(1) with two variables
  - Great intro problem for DP — understand overlapping subproblems here

---

### 17. **Validate Binary Search Tree** (LeetCode #98)
- **Difficulty:** Medium
- **What it tests:** BST properties, Recursion, In-order traversal
- **Companies:** Amazon, Bloomberg, Facebook, Microsoft
- **💡 Tips:**
  - Pass `(min, max)` bounds recursively: each node must be within its valid range
  - Alternative: in-order traversal must produce a strictly increasing sequence
  - ⚠️ Common mistake: only checking node vs. immediate children (not enough!)

---

### 18. **Coin Change** (LeetCode #322)
- **Difficulty:** Medium
- **What it tests:** Dynamic Programming (bottom-up/top-down)
- **Companies:** Amazon, Bloomberg, Goldman Sachs, Google
- **💡 Tips:**
  - `dp[amount]` = min coins needed for that amount
  - `dp[i] = min(dp[i], dp[i - coin] + 1)` for each coin
  - Initialize `dp` with `amount + 1` (infinity proxy)
  - This is the **unbounded knapsack** pattern

---

### 19. **Number of Islands** (LeetCode #200)
- **Difficulty:** Medium
- **What it tests:** BFS/DFS, Graph traversal, Matrix
- **Companies:** Amazon, Bloomberg, Facebook, Google, Microsoft
- **💡 Tips:**
  - For each unvisited `'1'`, run DFS/BFS to mark all connected land as visited
  - Count the number of times you trigger a new traversal
  - Mark visited cells by changing `'1'` → `'0'` (in-place) or use a visited set
  - Follow-up: Union-Find approach

---

### 20. **Linked List Cycle** (LeetCode #141)
- **Difficulty:** Easy
- **What it tests:** Fast & Slow Pointers (Floyd's Algorithm)
- **Companies:** Amazon, Apple, Bloomberg, Microsoft
- **💡 Tips:**
  - Slow pointer moves 1 step, fast pointer moves 2 steps
  - If they meet → cycle exists
  - Follow-up (#142): To find the cycle's start, reset one pointer to head and move both at speed 1

---

## 🥉 Tier 3: Very High Frequency (21–30)

### 21. **Container With Most Water** (LeetCode #11)
- **Difficulty:** Medium
- **What it tests:** Two Pointers, Greedy
- **Companies:** Amazon, Facebook, Goldman Sachs, Google
- **💡 Tips:**
  - Start with widest container (left=0, right=end)
  - Move the pointer with the **shorter** height inward
  - Intuition: reducing width is only worth it if we gain height

---

### 22. **Longest Palindromic Substring** (LeetCode #5)
- **Difficulty:** Medium
- **What it tests:** Expand Around Center, DP
- **Companies:** Amazon, Microsoft, Cisco, Facebook
- **💡 Tips:**
  - Expand from each index as center (handle both odd & even length)
  - O(n²) time, O(1) space
  - Manacher's algorithm is O(n) but rarely expected in interviews

---

### 23. **Word Search** (LeetCode #79)
- **Difficulty:** Medium
- **What it tests:** Backtracking, DFS, Matrix
- **Companies:** Amazon, Bloomberg, Facebook, Microsoft
- **💡 Tips:**
  - DFS from each cell matching the first character
  - Mark cells as visited during recursion, **unmark on backtrack**
  - Prune early if character doesn't match

---

### 24. **Top K Frequent Elements** (LeetCode #347)
- **Difficulty:** Medium
- **What it tests:** Heap, Hash Map, Bucket Sort
- **Companies:** Amazon, Facebook, Google, Yelp
- **💡 Tips:**
  - Method 1: Hash map + min-heap of size k → O(n log k)
  - Method 2: Bucket sort (index = frequency) → O(n) 🚀
  - Python: `collections.Counter` + `heapq.nlargest`

---

### 25. **Search in Rotated Sorted Array** (LeetCode #33)
- **Difficulty:** Medium
- **What it tests:** Binary Search (modified)
- **Companies:** Amazon, Bloomberg, Facebook, LinkedIn, Microsoft
- **💡 Tips:**
  - Determine which half is sorted by comparing `nums[mid]` with `nums[left]`
  - Check if target falls in the sorted half → narrow accordingly
  - Every step must cut the search space in half

---

### 26. **Binary Tree Maximum Path Sum** (LeetCode #124)
- **Difficulty:** Hard
- **What it tests:** DFS, Tree recursion, Global variable
- **Companies:** Facebook, Amazon, Google, Microsoft
- **💡 Tips:**
  - At each node, compute max single-path sum (node + best child)
  - Update global max considering the "arch" path (left + node + right)
  - Return the single-path sum upward (can't split at a node when going to parent)

---

### 27. **Trapping Rain Water** (LeetCode #42)
- **Difficulty:** Hard
- **What it tests:** Two Pointers, Stack, DP
- **Companies:** Amazon, Bloomberg, Facebook, Goldman Sachs, Google
- **💡 Tips:**
  - Two-pointer approach: track `leftMax` and `rightMax`
  - Water at position = `min(leftMax, rightMax) - height[i]`
  - Move the pointer on the smaller max side inward
  - O(n) time, O(1) space

---

### 28. **Course Schedule** (LeetCode #207)
- **Difficulty:** Medium
- **What it tests:** Topological Sort, Graph, Cycle Detection
- **Companies:** Amazon, Facebook, Microsoft, Uber
- **💡 Tips:**
  - Build adjacency list from prerequisites
  - BFS (Kahn's): process nodes with in-degree 0; if all nodes processed → no cycle
  - DFS: track visiting/visited states; if you revisit a "visiting" node → cycle
  - Return `True` if all courses can be finished (no cycle)

---

### 29. **Invert Binary Tree** (LeetCode #226)
- **Difficulty:** Easy
- **What it tests:** Tree recursion, BFS
- **Companies:** Google (the famous Max Howell tweet!), Amazon
- **💡 Tips:**
  - Recursively swap `node.left` and `node.right`
  - Base case: if node is null, return null
  - 3 lines of code — but understand it deeply
  - Can also do iteratively with a queue

---

### 30. **Serialize and Deserialize Binary Tree** (LeetCode #297)
- **Difficulty:** Hard
- **What it tests:** Tree traversal, Design, String parsing
- **Companies:** Amazon, Facebook, Google, LinkedIn, Microsoft
- **💡 Tips:**
  - Use pre-order traversal with a marker for null nodes (e.g., `"#"`)
  - Serialize: DFS, join values with delimiter
  - Deserialize: split string, use a queue/iterator, recursively reconstruct
  - BFS (level-order) approach also works

---

## 📊 Quick Reference Cheat Sheet

| Pattern | Problems |
|---|---|
| **Hash Map** | #1, #5 (alt), #9, #12, #13, #24 |
| **Two Pointers** | #8, #11, #27 |
| **Sliding Window** | #2, #11 |
| **Stack** | #3, #27 (alt) |
| **Linked List** | #4, #14, #20 |
| **Binary Search** | #25 |
| **BFS/DFS/Tree** | #15, #17, #19, #23, #26, #29, #30 |
| **Dynamic Programming** | #6, #16, #18, #22 |
| **Greedy/Intervals** | #2, #7 |
| **Graph** | #19, #28 |
| **Design** | #10, #30 |

---

## 🎯 Final Study Tips

1. **Pattern over memorization** — Learn the 10–12 core patterns; most problems are variations
2. **Easy → Medium → Hard** — Nail the easy ones first; most interviews are medium-level
3. **Talk while you code** — Interviewers care about your thought process as much as correctness
4. **Time/Space complexity** — Always state Big-O after solving
5. **Edge cases** — Empty input, single element, all duplicates, negative numbers, overflow

Good luck with your interviews! 🚀
