Pull to refresh

From Zero to Hero: LeetCode

Level of difficulty Medium
Reading time 8 min
Views 21K

This is a translation of my article in Russian

In this article, I want to write about my experience of interacting with the LeetCode platform, and describe my preparation for an interview in FAANG similar companies by breaking it down into levels.

The whole article is written based on my experience, the numbers are very rough, I do not pretend to be objective, perhaps there are best practices on how to solve LeetCode problems, it would be cool if you share your experience in the comments.

Level -1. Solved problems less than 10


How to determine

100% solvable problems at this level - Easy -. I singled out this level because it was my level at the beginning, and I think the level of many who have not done such tasks in their lives.

At this level, you can't solve the very first and popular LeetCode problem - Two Sum by any means, brute force, optimal, doesn't matter.

How to get to the next level

The time it will take you to go to the next level is about 2-5 hours without a break.

Everything is quite simple, at this level you don’t need to delve into algorithms and data structures, you need to get used to the platform itself, understand the structure of tasks, you need to carefully read the description of the task, look at the examples that we are given (input) and what we need to get (output), submit the problem and understand that there is such a thing as edge cases, when your solution covers 3 examples that you were given, but the remaining 60 test cases for some reason fall down.

After you have covered all the cases, look at the solution of other guys in the Solutions section, who made a solution better than yours, Runtime and Memory graphs. Until you have to think about what these charts are, study all this at the next level.

You need to solve the simplest problems on the leetcode, they are similar to the ones you solve at work :) Where can I find them? Everything is very simple. Go to Problems -> Easy -> Sort by Acceptance.

Look at the first 20 tasks and solve the ones you like, you need to solve about 10. It doesn’t matter how you can solve it with the most stupid brute force, in your favorite IDE with all the tips (but please don’t use ChatGPT :), the main thing is to pass tests and finally feel the taste of victory on the leetcode. The best way to get motivated is small victories, don't forget about it, let's move on!

Level 1. Noob. Solved problems 10-50


How to determine

100% of tasks solved at this level are Easy.

You can already solve tasks with an Acceptance level of 70-80% brute force in your favorite development IDE. You understand the simplest data structures - arrays, dictionaries, linked lists, queues, stacks. Of course, you use algorithms, but you don’t understand what’s inside, just type .sort()

How to get to the next level

The time it will take you to go to the next level is about 25-40 hours without a break.

To get to the next level, you need a BASE. You have to suffer at this level, but it will be much easier further on. You need to take a pen and a notebook and go to study algorithms and data structures. I propose to start by studying the neetcode.io resource, especially its RoadMap, because I myself use it and consider it the best resource for those who roll into algorithms.

Roadmap from Neetcode
Roadmap from Neetcode

Choose the first section, what is there? Oh yes, arrays. Go and read a few articles, outline, draw, drive into your head what this array looks like, never It will not be superfluous to refresh your knowledge. Also look into the complexity of inserting, deleting, and reading.

Yes, be careful here. If you have not studied in detail what Big O is before, please go read, review and watch a few videos on how it is calculated, in time and from memory. Ok, now you understand what the Runtime and Memory graphs were after solving the problems.

You need to consolidate the theory with practice, open a certain section and solve all the Easy tasks (if you want more, you can go to the Practice tab in NeetCode All). And further down the list, study the theory of the sections presented, consolidate with practice with easy tasks. At this stage, it makes no sense to go further than the Priotity Queue - Graphs - 1DP level on the roadmap.

Advice on how to solve problems, which I have heard many times, and I put it into practice myself. Set a timer of 45 minutes, if you haven't decided in half, go and watch the solution video (algorithm, no code!) from NeetCode or other bloggers, try to implement the algorithm in code. If it didn’t work out here, then carefully rewrite the solution and delve into what is happening in the code, debug and watch each step. It will be good if you describe each step that happens in the comments to the code to make sure that you understand the solution.

Let's go further!

Level 2. Beginner. Solved problems 50-100
How to determine

70% of the tasks solved at this level are Medium, the other 30% are Easy

You are a great! According to my calculations (Solves problems -> beats), <25% of all programmers from all over the world reach this level.

Finally, you can solve a problem like TwoSum by brute force without peeping, and even possibly optimally. You already understand such data structures as trees, graphs, priority queue, solved problems in different beautiful ways: two pointers, binary search, sliding window, etc.

Most likely, you solve most problems with hints, looking at the condition, you understand how to solve problems, what algorithm to use, what optimal solution is needed, but you cannot write it in code.

How to get to the next level

The time it will take you to move to the next level is about 25-40 hours without a break.

At this level, you need to solve the remaining medium tasks from the threadcode roadmap. In my experience, middle tasks are distinguished by a large number of edge cases, and more intricate task conditions, algorithms and data structures are the same.

If on an easy task it was necessary to simply use binary search (it is even possible that this is stated directly in the task conditions) in order to find a certain number from a sorted array, on a medium one must first sort (perhaps, for example, it may not be just an array, but more complex data structure), then use binary search, then do some other manipulation to get the answer. On easy, it’s much easier to guess that in a certain task you need to use a different algorithm, on medium, you first need to do some manipulations with the input data and then use an algorithm that will allow you to optimally perform this task.

At this level, you need to finish with the theory of Computer Science, for this it would be nice to study in more depth such algorithms as dynamic programming, recursion, backtracking, greedy, divide and conquer algorithm, floyd algorithm, gauss algorithm, more complex data structures, different variants of trees, what are the graphs and ways to optimally solve such problems (DFS, BFS).

Popular algorithms
Popular algorithms

As you solve problems from the roadmap, you will come across all these algorithms and data structures. If you want more, go to NeetCode All and take the task from there. Also in the leetcode, you can sort tasks by tags, for example, dynamic programming, Problems -> Tags.

Level 3. Amateur. Solved problems 100-300


How to determine

90% of tasks solved at this level are Medium, 5% are Easy, 5% are Hard

When you have 100 solved problems, you should already know all the algorithms and data structures that can get into 99% of the problems on the leetcode and, in general, in the algorithmic sections of interviews. The level of writing your code should be brought to automatism, you should quickly understand what data structure, how to go through, how to change a certain element, in what ways it is better to optimally solve a problem for a particular data structure, how recursion works, where to put pointers, how determine the middle from an array of numbers, how to reverse trees after all! You must be a pro in the basics of Computer Science. If this is not the case yet, it is worth stopping and going through all the theory so as not to waste any more time on it, because only practice will follow. You can read, for example, this book, it is easy to read, but I would advise you to read other articles and watch a few videos.

How to get to the next level

The time it will take you to get to the next level is about 150-200 hours without a break

I think at this level, a lot of people will drop out of leetcode thinking they can already pass the interview. I believe that this is not enough, because even if you can solve some problems without prompting and meet the time limit, in the interview itself, your stress level will be completely different, and you will most likely fail.

In order to reach the next level, you only need to solve and solve problems, mostly middle ones, because with a high probability they will ask you at the interview, so it’s better to automate the solution of such problems in the best way.

At the interview, you will have 45 minutes to solve the problem, along with an explanation of the terms of the problem. At this stage, you should aim to solve the problem in the optimal way in 25 minutes, because the interviewer can add a follow up to the problem and you must solve it in the initial allotted time. Reach 300 tasks and move on!

Level 4. Expert. Solved problems 300-1000


How to determine

70% of tasks solved at this level are Medium, 25% are Hard, 5% are Easy

This is the level where you can already apply to FAANG like companies, if you are in the lower bound of solved problems, you can pass if you are lucky with the interviewer and the problems will be +- in industry standards, without tricky edge cases and a bunch of dynamic programming.

Optimally, if you have solved 500-600 problems, rarely seen reviews of those who did not pass the algo section with such a level of solved problems, if you are closer to 1k solved problems and did not pass the algo section, you urgently need to improve your English, with 99% probability the interviewer I didn't like your communication skills.

Yes, at this level you need to improve your communication skills, if the interview is in English, then it too. This is very important, even if you solve the problem, but do not explain your thoughts along the way, you will be overwhelmed.

Here are the criteria Google evaluates (from ex googler):

  1. Algorithms. At the beginning, without writing a single line of code, you must explain how you will solve this problem, what algorithms and data structures you will use, what time and memory complexity they have. First, it is better to offer a brute force solution, if there are several optimal ones, offer everything.

  2. Coding. You should state the previously voiced thoughts on solving the problem in the code. Ideally, you should write highly readable code with well-named variables, methods, etc. And, of course, the written code should work and cover all cases, even if you don’t run it, which, most likely, will be the case, since you will write everything on a blank sheet, without any syntax highlighting (it’s better to prepare for this if you will be prompted to write in some online code editor, we will assume that you are lucky).

  3. Communication. This is the hardest part for all non-English speakers or just introverts. You should comment on every line you write, why you are writing it and where it will lead. Also, you should talk about general and professional topics during the interview, here your soft skills can be checked, even before reaching the behavioral stage.

  4. Problem solving. From the very beginning, you should put the conditions of the problem on the shelves and ask clarifying questions and find out what edge cases can be. As you write code, you should divide tasks into subtasks, if necessary, do not write chaotically and rewrite everything, your algorithm should be 100% understandable to the interviewee.

The screenshot below describes the structure of how a Google candidate is evaluated. Screenshot taken from here - starting at 52:00

Метрики оценки на алго секции от бывшего работника Google
Метрики оценки на алго секции от бывшего работника Google

It’s also a good idea to start doing mock interviews at this stage if you’re purposefully preparing for interviews. Mock interviews will allow you to build the structure of the interview in your head, hone your communication skills in English and reduce stress already when passing a real interview. On the advice of experienced people, you need from 10 to 50 mock interviews to bring this skill to automatism.

How to get to the next level

The time it will take you to move to the next level is about 300-600 hours without a break

Here is a stop for anyone who wants to get into any FAANG+ company. It only makes sense to go further if you are really passionate about sports programming and want to become world champions or win other competitions.

There are many competitions and challenges on LeetCode, ranging from daily tasks given to you by the leetcode, to world competitions where you have to solve several problems for a while.

Gentlemen, here is my stop, go ahead!

Level 5. God. Solved problems 1000+


How to determine

You already know that, it’s better to share lifehacks in the comments on how to learn effectively and become like you.

How to get to the next level

To infinity and beyond?

Buzz Lightyear
Buzz Lightyear

Tags:
Hubs:
+3
Comments 0
Comments Leave a comment

Articles