Don’t Study 500 LeetCode Problems, Do This Instead
We’re going to go through a bullet proof study plan to get you prepared for 90% of interviews that require data structures and algorithms.
Besides passing interviews, the benefits of learning data structures and algorithms are:
- increased problem solving ability
- exposure to fundamental computer science concepts
- confidence
Unfortunately, most people do random LeetCode problems expecting to come out on the other end interview ready. That’s like going to the gym with no plan, throwing random weights around and expecting to get buff.
Study concepts, not problems.
I spent over 10k learning data structures and algos over the years. I’m going to break down exactly how I went from not knowing Big O to making it to the final rounds at companies like Google and Facebook and landing offers from high growth startups.
Here’s what you should study, in order:
Big O Notation
Estimated Study Time
- 1 day
Concepts:
- Space vs time complexity
- Linear time
- Logarithmic time
- Factorial time
- Constant time
- Exponential time
How to Study:
- Read: https://www.freecodecamp.org/news/big-o-notation-why-it-matters-and OR https://www.digitalocean.com/community/tutorials/js-big-o-notation#o-n-2
- Write the Big O next to every problem you solve
Sorting and Searching
Estimated Study Time
- 1 week
Concepts:
- Merge sort
- Quick sort
- Bubble sort (and why you would never use this!)
- Hoare vs Lomuto partitioning https://www.geeksforgeeks.org/hoares-vs-lomuto-partition-scheme-quicksort/ (BONUS points)
- Binary Search
- Also — know the Big O space and runtimes for each of these algos
How to study:
- Create each sorting and searching algo from scratch
Stacks and Queues
Estimated Study Time
- 1 day
Concepts:
- Stacks
- Queues
- LIFO
- FIFO
How to study:
- Create a stack and queue from scratch
Heaps
Estimated Study Time
- 2 days
Concepts:
- Max heap
- Min heap
- Priority queue
How to study:
- Create a max and min heap from scratch
- It can be difficult to know when to use one of these structures and they are not native to JS — know some good use cases for them
Trees and Tries
Estimated Study Time
- 1 week
Concepts:
- Binary trees and Binary search trees (there’s a difference)
- Depth first search
- Breadth first search
- What the heck is a trie?
- In-order traversal
- Post-order traversal
- Pre-order traversal
- N-ary trees
How to study:
- Create a binary tree, binary search tree and a trie from scratch
- Create all the different methods for sorting and searching your trees/tries
- Think of the use cases for tries and trees — when and why would you use one over the other?
Recursion
Estimated Study Time
- 1 week
Concepts:
- Recursion vs backtracking
- Call stack
- Stack overflows (the concept, not the site)
How to study:
- Solve problems that require finding combinations and permutations
- Create a recursive template you can leverage — you should see patterns emerge for both backtracking problems and recursive problems
- This is often the most difficult concept so plan to come back often
Linked Lists
Estimated Study Time
- 1 week
Concepts:
- Singly linked list
- Doubly linked list
- Benefits of a LL over a stack or a queue
How to study:
- Create an LRU cache (look it up) leveraging a LL
- Practice problems requiring you to remove the nth-child in a LL
- Understand when to use a LL over a stack or a queue
Graphs
Estimated Study Time
- 1 week
Concepts:
- Directed vs undirected graphs
- Adjacency list
- Adjacency matrix
- Depth first search
- Breadth first search
- Djikstra and A* algorithms
How to study:
- Create graph structures using adjacency and matrix representations with DFS and BFS methods
- How is DFS on a graph different than a tree? BFS?
- Solve “flood-fill” problem
- Solve problems where you need to detect loops
Dynamic Programming
Estimated Study Time
- 1 week
Concepts:
- Dynamic programming vs recursion
- Top down vs bottom up memoization
How to study:
- Solve Fibonnaci using DP
- Levenshtein Distance
Miscellaneous but Important!
Estimated Study Time
- 2 weeks
Concepts:
- 2 pointers
- Frequency counters
- Sliding window
- Detecting intervals
How to study:
- Look up <concept> + Leetcode and solve at least 2 problems under each concept
Conclusion
Holy moly, that’s a lot to study… or is it? I gave fairly aggressive estimates for how long I would expect you to take to study the bare minimum.
It’s enough to get a solid understanding of the most common concepts and can be done over a couple months.
For most interviews, that’s really all you need.
If you are NOT solely interviewing with companies who have a fetish for white-board interviews check out all the free resources I have here: https://yourcodecoach.com and then get my freakin’ course (that’s not really a course) https://www.yourcodecoach.com/not-another-course