A reasonable Leetcode guide to prep you for a fun Software Engineering career

I am a software engineer at Ravacan where we build tools to automate supply chains and sourcing. The advantage of working at early stage startups is that you get to build unique tools. These tools often require concepts from Computer Science like Graph algorithms, a solid understanding of time complexity etc…

If you don’t want to spend your life just fixing API endpoints, you must invest time in learning CS fundamentals.

Recently I wrote a Leetcode “curriculum” for my friends and I’m sharing it here as it may be useful to others.

What

I call that a horizontal pass (through the tags).

Then do the same for Medium difficulty.

I call that a vertical pass (through difficulties).

Once you’re done with Easy and Medium problems, you can do the top 10–15 Hard problems.

* means tag doesn’t have that many problems. Just do a few.

How

Before doing each tag, I recommend reading the corresponding CLRS chapter and understanding all the theory behind it. Watching these lectures helps a lot! MIT follows CLRS, so it’s a good combination.

Also, these channels are great resources for difficult concepts: this for most problems, this for good explanations, this to see how a competitive programmer solves, this for graph theory, this for harder problems. And of course any other videos you find when searching for a specific problem.

I recommend spending 30min-2h per problem such that you can think deeply. That’s why doing more than 4 problems/day is too much to handle.

At first (especially with arrays, strings and trees) you will be looking at solutions often to get familiar with the concepts. Gradually, you want to read solutions less and less, while spending more time thinking.

Classic Problems

Array: 1, 15, 560, 48, 46, 78, 215 (quick select is massive. Used in quick-sort too!).

LinkedLists: everything you’ll see under “Top 100 liked questions” & 141.

String: 20, 22, 227.

Binary Search: 33, 34 (Erichto has a good video on this one).

Tree: 104, 102 and most Easy & Medium problems from the “Top 100 liked questions” list. Trees are a great topic to master recursion! Do many tree problems.

Graphs: 207 (watch this video for a great explanation), 200. DFS & BFS are very important! You should be able to create a graph and perform iterative/recursive DFS or BFS (BFS is iterative only) comfortably.

Trie: Do all easy problems & 208.

Stack: 232, 155, 716.

Time & Space Complexity

As a rule of thumb, most problems above have a linear time complexity solution. A few have quadratic and a handful exponential. Space compl. is also very important and most problems have constant or linear space compl.

You should know the best time & space complexity for every problem. An interviewer will ask you for it.

When solving a problem, first come up with a naive solution (we call that brute-force). The brute-force solution will usually be quadratic (or worse) in time.

Always ask yourself what the time & space complexity of your solution is. Next, try to optimize it. Finally, compare it with the solution and make sure you understand and internalize it. Write it yourself (never copy!) and come back to that problem in a week. See if you remember how to do it. In fact, that is a general strategy for all problems. Every 1–2 weeks, do a review by revisiting some problems that challenged you. Try to solve them again and again.

Conclusion

Follow me on Twitter for more Software Engineering and Blockchain content.

Software Engineer