Leetcode

Leetcode.com is a website on which you can solve interview questions and read some other interview related materials. Currently, it is probably the best way to practice for coding interview rounds.

Many problems on Leetcode come from the real interviews in different companies. When I passed interviews, about 25-30% of the problems I was asked I solved on Leetcode before, and about 70% of the problems had something similar on Leetcode.

I feel that anybody who solves 300–400 problems on Leetcode has a good chance of passing almost any coding interview round.

How to solve problems on Leetcode

There are several tips for the most optimal problem solving on Leetcode:

  • Avoid using IDEs or any code editors, and solve the problem right in the web editor on the Leetcode page, or on a whiteboard. In the real interview, you won't get to write your code in the real IDE as well, so it is better to get used to that.
  • Don't rush to read the solution too fast – give yourself some time to think about the problem yourself. After all, you are not only learning how the problems are solved, but also training your brain to come up with the solutions. If you are stuck on a problem, it is okay to spend several hours or even days to think about it before giving up.
  • After you solved the problem, be sure to check its official solution (if available) and several top solutions from the discussion page. This way you may learn about some better ways to solve the problem. Also, check some solutions in your programming language to see what you may learn from the code.
  • Be sure to write good code in your solution. Generally, during the interviews, you are expected to write clean, well-styled code, like something that you may write at work.

How to pick the problems to solve on Leetcode

There are more than a thousand problems on Leetcode, but not all of them are great. Here is some advice on how to pick the problems to solve:

  • Problem difficulties are not always accurate, so don't skip easy problems. They may also have some interesting patterns that can help in harder problems.
  • Hard problems, on the other hand, are often too complicated and tedious, so solve them only when you are comfortable with easier problems, and mix them with easy and medium problems as well. Before my interviews, I solved 333 Leetcode problems – 115 easy, 160 medium, and 58 hard.
  • For choosing what to solve next, I recommend filtering by company tags (choose the companies you want to apply to) and frequency. The following problem lists are also pretty good: Top Interview Questions, Top 100 Liked Questions, Top Google Questions, and Top Facebook Questions.
  • Problems with numbers larger than 800 usually come from Leetcode contests and often have lower quality. They also usually don't come from the real interviews, so I don't recommend solving them.
  • For practicing particular algorithms and techniques, check out the problems from the Algorithms section.

Practicing speed

In the real interview, you are often expected to solve two problems (or a problem and a follow-up problem) in 45 to 60 minutes. Besides the ability to solve problems, you may find that solving them fast is also very important. Here are some tips on how you may practice your speed:

  • Have a dedicated speed training practice sessions. Choose two random problems (or two problems with the difficulty you want to practice), and try to solve them as fast as possible – ideally, try to solve them in about 45 to 50 minutes. Be sure to still write good quality code, and you can also practice explaining your solutions aloud as you code.
  • Leetcode contests are all about speed, so you can try participating in them as well.

Leetcode contests

Leetcode hosts about 1-2 contests a week with brand new problems. These are fun to participate in, and they may be helpful to train your speed. On the downside, problems in the contests are often of lower quality. Also, the speed required to participate well in the contests is something like 2-3x of what you need in the real interviews, and problems may be much harder than a usual interview as well.

If you participate, be sure to still write good, clean code, and don't be too discouraged if you don't perform that well. Leetcode contests are hard, and are not directly related to the interviews – participate only if you are already comfortable solving problems and want to challenge yourself.

Other Leetcode features

There are a lot of other Leetcode features – mock interviews, articles, and so on. Try all of them, and see what you find useful.

Leetcode Premium

Leetcode also has a Premium subscription that opens you more features and problems. I found it only somewhat useful – the most helpful features to me were company problem lists and a frequency feature.

Leetcode Premium is definitely not required to prepare well for the interviews. And if you decide to try it, it is enough to buy it for just 1-2 months. For example, you can buy a Premium subscription one month before your planned phone or onsite interviews. As a bonus, paying for the Leetcode Premium subscription can be additional motivation to practice more during the time that you have it.

Action Items
1. Explore Leetcode features.
Explore Leetcode features to know the website better and see what you will find useful.
2. Solve 200 Leetcode problems.
Solving problems on Leetcode is really important, and it is probably the best way to prepare for the coding interviews. 200 solved problems should give you a very good base.

This is a bit longer than a usual action item, so you may come back and mark it completed later, once you explore other sections of this website and solve enough problems.