2020 has been a ride.

I no longer think it’s satisfactory to go through my 2020 learning plan. A lot of those priorities were with the expectation that I wouldn’t be worried about keeping my job this year. That is no longer the case... for anyone.

The only priority for the near future is learning stuff for interviews. In my line of work, that involves 3 areas of study: Algorithms, System Design, and practical React/Node projects.

I do enough React and Node at work for now, and studying System Design is best done closer to actual interviewing. So, I’m going to be focusing on getting much better at algorithms for the near future.

I am constricted by two things: I only want to invest 1 hour after work each day, or less than 8 hours a week total. I also only know JavaScript, and don’t want to work in a language I don’t feel great about yet (ie Java).

So, assuming you’ve done some practice problems, solved some easy LeetCode problems here and there, and have some familiarity with how to solve these problems, **how do you level up and get from Two Sum to Binary Search Trees assuming no formal CS background?**

Here’s how I’m doing it:

## The Curriculum

There’s a few steps to learning algorithms. If you jump too quickly into a curriculum, you lose the context of how this actually relates to what you’ve already done. If you practice for too long without consulting outside sources, you won’t even know what the questions are actually asking of you. Balancing both at certain milestones is critical.

I am definitely at the point where I’ve done enough of the array and string manipulation problems and really need guidance and structure around what knowledge gaps I have. **I need the fundamentals.**

There’s a few different ways to go about this, but after failing to learn this enough times, I decided that I need a very specific feedback loop.

First, reading about the new concept. Reading could be actually reading or videos. This should be fairly practical and contain as little vocabulary as possible. Diagrams are good. Example problems are just going to be confusing at this point.

Then, I need to be thrown in. Give me a problem. Let me fail at it. Let me hack my way through it and not understand it at all.

Lastly, I need a review of the problem itself, not the concept again. I need to not only see the proper solution, but see the process of the proper solution.

Do this enough times, and the patterns start to match. Note that the reading shouldn’t happen for every new problem. The Practice-Review loops should be happening more often.

As far as I can tell, InterviewCake has the best kind of feedback loop for this. There’s some other services that handle Question -> Review, but the hardest part for me is getting that list of step-by-step curriculum that explains the fundamentals I’m lacking. Due to Covid19, it is currently $29, and although I can’t recommend truly recommend it yet, I’d at least recommend looking at it.

I’d say InterviewCake handles the Reading -> Question. It partially handles the Review part, but I think I’ll need supplementary materials.

Alongside InterviewCake, there are a few things I’ll be doing:

**Reading:** Easy to Advanced Data Structures by William Fiset. This was recommended to me by Chris’s excellent blog post about his algorithm studying. It’s nice to have readings on InterviewCake and video explanations on YouTube to look for.

**Questions:** LeetCode. What else is there to say? I’m not doing anything special with this yet, just practicing alongside what I’ve already covered on InterviewCake.

**Review:** The great thing about how popular LeetCode is is that I can look up solutions to the question on YouTube. This tends to require a basic-level competency with Java and Python. I believe spending a weekend on these two languages, enough to understand how to translate that to JavaScript, is worth it.

The review on YouTube is probably the most vital part. It’s all fun and games to solve Two Sum, but how do you really *do* Two Sum? How do you optimize it? What are you missing? Pattern matching will build over time, but just solving problems isn’t enough. You have to know what the right answer is to get it next time. Mentors or looking at other people’s solutions and how they got there are the only way to do this better and better over time.

## The Process

I have a job. I can’t devote the entirety of my life to this. I’m going to be trying to do one question per day, which may encompass a reading beforehand, and definitely encompasses a review after.

I want to put these questions into some sort of a spaced repetition system to come back and do them better eventually, but I think there are enough questions on LeetCode that I don’t really need to repeat anything.

So, for example —

I’ll log into InterviewCake and see what’s next on my course list. If there’s a reading, I’ll go through it. I’ll also cross-check the Data Structures playlist to watch any videos related to that topic.

Then, I’ll go through an accompanying problem. If I’m running out of accompanying problems in the course, I’ll head over to LeetCode and find something in that topic realm.

I’ll solve the problem, save that solution, and go to YouTube or the InterviewCake hints to review. I’ll mark down what I missed and what the optimized solution was.

Tomorrow, I’ll do the same thing again.

## How I’m Problem Solving

Algorithms aren’t just about spamming the LeetCode submit button. There’s a process. I’m stealing most of this process from Chris’ excellent blog post about his study process, but I really like it.

### Keep a Problem Log

I think this is what separates people who “get algorithms” from people who claim they’ll never be able to understand them. Write down every single problem you solved and take notes about it.

What comes in those notes will come naturally — the problem, the category, notes on patterns used to solve it, a list of solutions you have as you go through the problem more than once, notes from your review.

If you’re doing this on paper (I would), there should also be an accompanying e-log with your solutions easily accessible to be copy/pasted. LeetCode itself saves all of your submissions, but that’s a bit too messy for me.

This is a fairly formal book and not really a place for freeform thinking. This is different than a scratch pad.

### Solving the Problem

I’m just going to copy this from Chris’ article

Solving a problem took these steps:

Read the problem, understand the inputs and what you're expected to output.

Think about what "family" of questions this question falls under.

Think about what are the best data structures to use for the approach.

Think about my actual approach to the problem.

Determine whether there was a faster way to solve the problem (if so, go back to step 3).

Hand-write the solution into a dry erase board or in my notebook.

Re-read the solution I just wrote, see if it would compile and if it would actually solve the problem. Fix any bugs if so.

Copy the solution, word for word, into the LeetCode editor.

I think this is great. I especially like the parts that tell me what to think about exactly. I often hear that advice, but I’m not sure what I’m looking for. I’m actually making prompts in my scratch pad for those questions.

This is important so that I’m actually documenting *this is an array manipulation problem*, *I should probably solve this using objects*, etc., etc.. before I even dive into the code.

Secondly, it’s important to write down the solution on paper or on a whiteboard before typing it into LeetCode. Don’t give into that convenience. Even if you have a code editor in an interview, you won’t be in an environment you’re comfortable in, so you should be able to write a solution by hand without any conveniences that editors allow (ie. `console.log`

!)

If your first solutions fail, that’s okay. I’m giving myself leeway to debug it in LeetCode then to try and find my way to a solution. I expect the frequency at which that will occur will drop the more I practice.

It’s also important to time yourself (and to note that). It’s okay to take more time than needed at first, but over time, try to keep it under 30 minutes for your first solution.

Don’t try to do everything perfect at once. First, just solve the problem. Then, solve it on the first try. Then, solve it optimized. Then, solve it optimized, on the first try, and within 30 minutes.

You will get better and make breakthroughs.

### Reviewing

Remember, **it’s not enough to just solve the problem**. There are more optimal solutions. Hackiness isn’t the point here.

Self-taught people will see Two Sum as the #1 question on LeetCode, solve it in O(n^2) and legitimately go through life thinking that they’re okay. Two Sum has an optimal solution. It’s just one of those things that you have to know to know.

I think it’s important to do that frequently, and although there are courses that will teach you all of those tricks more upfront, I’m better at reflecting on tricks after I’ve already tried it. Watching competitive programmers on YouTube is the best way for me to review my work here.

…

That’s about it. I’m going to be going through one of these problems every day for 6 days a week.

With consistent practice and an understanding of where to get that knowledge that fills the gaps of “you don’t know what you don’t know,” I believe it’s possible for any self-taught engineer to become fairly competent in algorithms in a few months time. I’ll report back when I’m a pro.

Posted on by:

### Radhika Morabia

Software Engineer at OpenTable. Focused on JavaScript. I write tech about careers, tech, and the industry at https://tinyletter.com/rmorabia

## Discussion

Data Structures and Algorithms Specialization Course on Coursera can help. And I have also started a series on data structure and algorithms for beginners Revisiting DSA Please take a look at it

Thanks for the link! I've been looking further into more academic materials as well.

If you are looking for a more theoretical perspective on algorithm design, you should look into "The Algorithm Design Manual" by S. Skiena. It is as academic as they come, but a bit more gentler than other books in the same area of expertise. :)

I recommend this book too. It’s much more practical and hands-on than something like the Cormen book that I had to use in school.

Thanks! I've heard this before, but I'm still a step further back in trying to understand Data Structures before I jump into Algorithms. As far as I can tell, ADM kinda skips over that and assumes you're very familiar with those. Any recs for bottom-up data structures textbooks?

Yeah that’s a good call, data structures before algorithms. I don’t have any personal go-to DS books though, sorry. The one I used was based around C and I’m not sure what it was called but I don’t remember it being particularly good anyway.

I've looked into some in Python but really just settled on articles/Leetcode's modules + YouTube videos. Seems that CS students are rushed through this topic in the second CS class, along with other topics.

Hi again, read the follow ups and thought I'd give you an opinion. If you want to learn Data Structures, again, academically, then I would recommend Data Structures and Algorithms in Python/Java by Goodrich, Tamassia and Goldwasser. I went through the Java version, whenever I have an interview coming up I still go through the book as a reference point.

I saw that you are primarily a JavaScript developer and you're concerned with language-specific resources. I have not looked into JS at all for data structures, I worked with it a few years ago and I wouldn't recommend it for implementing your own data structures. Python would be a closely related language that you should look into. In general, data structures are much easier to implement in an object oriented language like Python / Java.

Irrespective of what language you decide to go with, try to find resources that are a bit more rigorous in nature and explain more than what the data structure needs to do and the interface it exposes, it will pay off in the long run. That's the reason I like Goodrich et al's book, it has theoretical rigour and is focused on good practices and design patterns that can be leveraged when you implement a data structure yourself.

As a minimum: linked lists -- stack/queue -- dynamic arrays (vectors) -- binary search trees -- heaps.

Hope this helps!

Really excellent advice here! As a CS degree person who spent hours doing algorithms homework, I think building up your mental library of pattern matching is really the goal with this stuff. Eventually you start to notice the little clues in the questions (or at least get very very suspicious when they give qualifiers like “you can assume the list is sorted”).

Your suggestion that you just “need to know” that Two Sum has an optimal solution is good, and I’d generalize it even further, to know that the O(n^2) solution is

almost neverthe optimal one. Some of the hard ones have n^2 as an optimal solution, but that usually means the easy/obvious one is way worse. Data structures are usually a good hack for making things faster, like for “I need to keep looking up values in this array and it’s killing me” -> loop it once (n), put every item in a hash (n), and look them up all you want at O(1).This is great advice I've learned the hard way over the past 2 years. I think I (and a lot of self-taught people I know) just go into algorithms thinking that the end solution is just to be solved. If I can brute force solving this sorting problem, then I'm good!

We hear the words merge sort and binary sort, but I don't think I was ever explicitly told: These are patterns that already exist. You learn them to use the patterns in the right circumstances, with the right worst case O(whatever). The Big O cheatsheet helps you decide

what to use, nothow to solve it.This breakthrough recently was

hugefor me and now I finally see a light at the end of the tunnel in understanding this stuff! Also yes, my goto after so many times where I had O(n^3) solutions is now... When in doubt, use a Map!Hi Radhika - I wrote a book exactly for people like you, who want to understand MORE than just a quick "here's Big-O". I'm self-taught and I was exactly in your place 5 years ago so I started researching and I wrote it all down:

bigmachine.io/products/the-imposte...

I translated that into interview prep here as well:

pub.bigmachine.io/coding-interview...

Anyway I don't mean to self-plug even though I am. If it helps yay!

Hey Rob! I've read your book and really liked it! Didn't realize you also had interview prep stuff. Checking it out now. Thank you!

Love this post friend ✨

Thanks! I wrote it entirely for myself, studying with @sophia_wyl right now. Never expected it to get this popular (even without Twitter lol), but I guess it's the right time for a lot of people!

Hope you're doing well & staying safe!

Thanks for the post Radhika! I am a front end developer, and I started learning algorithm and data structures a while ago. But I felt that, JS isn't suited for such coding interviews. One of the recruiters told me that I can only choose Python, JAVA or C/C++. Some still have the impression that JS isn't a good OOP Language, and that might negatively impact the interview. I have also noticed that many coding challenge platforms don't support JS at all.

This is a valid point! Adjust as necessary if you have to learn a new coding language. Python is probably easiest for JS devs.

Great read, thanks for writing this. The post by Chris that you reference is a really good read, too. I'm in the process of diving more into Algorithms and DS' so this was a great time to read - I can't wait to follow your posts. I'm going to check out Rob Cornery's book, too.

I would like to suggest the Learn DSA series by Code Chef - codechef.com/LEARNDSA. It's particularly focused on competitive programming, but IMO it does have pointers to the material you should look up before you attempt to solve the problems.

Hi Radhika, thank you so much for sharing the detailed process of self-learning data structures and algorithms. I have recently started doing LeetCode learn cards. The problem statements are divided based on different data structure topics. The process I follow is. I don't see the solution unless and until I solve the problem on my own. Once I solve the problem then I document the solution approach, learnings, etc.

But, there are some problems for which I am absolutely clueless about the approach that needs to be followed to reach the solution. In cases like these do you see the solution first? Or how do you go about solving the problem?

At the moment I am not doing any external data structures and algorithms course. In coming blogposts of yours can you provide a review of the Interview Cake course curriculum?

Hey Mridu, I was exactly where you are now the last time I tried studying DS&A. I highly recommend, at this stage, to start a formal curriculum. I've been enjoying my mix of InterviewCake + that YouTube playlist I posted in the article. There's just so much that there's no way I could learn by myself by just viewing solutions.

I'll definitely write a review later down the line, for now, here's a quick summary of my thoughts so far: I like the pace and order of InterviewCake. The problems are good, they have a lot of hints which is really useful. But for the knowledge gaps of "What even is a linked list, really?" It definitely needs to be supplemented with something external. The readings are too sparse on its own.

I think that for... 90% of the problems that you don't have any idea of an approach for, it's some more academic style learning that we're lacking. Whether that's a certain type of data structure, a sorting algorithm, or trees, they're shortcuts that the problems just expect you to already know. You'll start to see there's hints in the language when they expect you to use a sorting solution, or a graph, or trees, or whatever.

Whether you supplement that through YouTube or a book or whatever, I really think that's the next step for you.

Competitive Programming 3 is an excellent resource if you want to learn data-structure and algorithms with the goal of acing coding interviews. The book helps you advance your skills in for developing the best solutions to well-known computer science problem as quickly as possible". Many of these well-known computer science problems can be found on leetcode. The way to drive home the knowledge is to do a bunch of leetcode problems related to the topic from the book as soon as you read it. You are going to retain the knowledge on data structures and algorithms a lot better if you immediately put it to use to solve problems on leetcode.

Radhika this is a great read. I run office hours to help folks practice for interviews.

I'd love to help out. You can book a slot here : calendly.com/chirag-jain/mock-inte...

Great read thank you

Any college/school students having a valid ID and GitHub account with access to GitHub Student Pack can get InterviewCake subscription for 3 weeks for free.

And thanks for the article.

This study plan is just nice .