Practicing is the best way to prepare for coding interviews. Years ago, I curated a list of the most important 75 questions on LeetCode. Many other LeetCode questions are a mash of the techniques from these individual questions. I used this list in my last job hunt to only do the important questions.
I shared this list on Blind to save peoples' time when revising and someone reposted this list on the LeetCode forums. It somehow blew up and became super famous in the coding interview scene, people even gave it a name - Blind 75. The Blind 75 questions as a LeetCode list can be found here.
Years later, I further distilled the list down into only 50 questions and spread them across a 5-week schedule. Here is the suggested schedule for revising and practicing algorithm questions on LeetCode. Sign up for an account if you don't already have one, it's critical to your success in interviewing!
When practicing, you are advised to treat it like a real coding interview and check through thoroughly before submitting. Consider even manually coming up with some test cases and running through them to verify correctness!
I've created a LeetCode list for the following questions (except the Premium ones). Feel free to use it to track your practice progress.
Week 1 - Sequences
In week 1, we will start off easy and do a mix of easy and medium questions on arrays and strings. Arrays and strings are the most common types of questions to be found in interviews; gaining familiarity with them will help in building strong fundamentals to better handle tougher questions.
- Two Sum
- Contains Duplicate
- Best Time to Buy and Sell Stock
- Valid Anagram
- Valid Parentheses
- Product of Array Except Self
- Maximum Subarray
- Merge Intervals
- Group Anagrams
Week 2 - Data structures
The focus of week 2 is on linked lists, strings and matrix-based questions. The goal is to learn the common routines dealing with linked lists, traversing matrices and sequence analysis (arrays/strings) techniques such as sliding window.
- Reverse a Linked List
- Detect Cycle in a Linked List
- Container With Most Water
- Find Minimum in Rotated Sorted Array
- Longest Repeating Character Replacement
- Longest Substring Without Repeating Characters
- Minimum Window Substring
- Number of Islands
- Remove Nth Node From End Of List
- Palindromic Substrings
- Pacific Atlantic Water Flow
Week 3 - Non-linear data structures
The focus of week 3 is on non-linear data structures like trees, graphs and heaps. You should be familiar with the various tree traversal (in-order, pre-order, post-order) algorithms and graph traversal algorithms such as breadth-first search and depth-first search. In my experience, using more advanced graph algorithms (Dijkstra's and Floyd-Warshall) is quite rare and usually not necessary.
- Validate Binary Search Tree
- Invert/Flip Binary Tree
- Non-overlapping Intervals
- Serialize and Deserialize Binary Tree
- Construct Binary Tree from Preorder and Inorder Traversal
- Top K Frequent Elements
- Clone Graph
- Course Schedule
- Binary Tree Maximum Path Sum
- Maximum Depth of Binary Tree
- Same Tree
- Binary Tree Level Order Traversal
- Encode and Decode Strings (LeetCode Premium)
Week 4 - More data structures
Week 4 builds up on knowledge from previous weeks but questions are of increased difficulty. Expect to see such level of questions during interviews. You get more practice on more advanced data structures such as (but not exclusively limited to) heaps and tries.
- Add and Search Word
- Implement Trie (Prefix Tree)
- Subtree of Another Tree
- Kth Smallest Element in a BST
- Lowest Common Ancestor of BST
- Merge K Sorted Lists
- Find Median from Data Stream
- Insert Interval
- Longest Consecutive Sequence
- Word Search II
- Meeting Rooms (LeetCode Premium)
- Meeting Rooms II (LeetCode Premium)
- Alien Dictionary (LeetCode Premium)
- Graph Valid Tree (LeetCode Premium)
- Number of Connected Components in an Undirected Graph (LeetCode Premium)
Week 5 - Dynamic programming
Week 5 focuses on Dynamic Programming (DP) questions. Personally as an interviewer, I'm not a fan of DP questions as they are not really applicable to practical scenarios and frankly if I were made to do the tough DP questions during my interviews I'd not have gotten the job. However, companies like Google still ask DP questions and if joining Google is your dream, DP is unavoidable.
DP questions can be hard to master and the best way to get better at them is... you guessed it - practice! Be familiar with the concepts of memoization and backtracking.
Practically speaking the return of investment (ROI) on studying and practicing for DP questions is very low. Hence DP questions are less important/optional and you should only do them if you're very keen to have all bases covered.
- Climbing Stairs
- Coin Change
- Longest Increasing Subsequence
- Combination Sum
- House Robber
- House Robber II
- Decode Ways
- Unique Paths
- Jump Game
- Word Break Problem
Dynamic programming course
If you want more structured algorithms practice, I recommend Educative's Grokking the Coding Interview: Patterns for Coding Questions course. This course essentially expands upon the questions here but approaches the practicing from a questions pattern perspective rather than data structures, which is an approach I also agree with for learning and getting better at algorithmic problems.