Wiki & FAQ > Information & Career > Interview Process > Preparations > Leetcode

Leetcode Strategy

Don't grind, bind to your mind.


One of the most common mistakes people make in preparation for technical interviews is grinding Leetcode. Mindless grinding serves no purpose. You must make an intentional effort at learning with the goal of true understanding.

There are various techniques to this but here is one to get you started.

Scheduling

First, set aside time for study and practice. For example, you could decide to Leetcode for an hour every Monday, Wednesday, and Friday. This amount of time could be enough if you already have a strong foundation, but you can adjust up or down depending on your experience level.

Topic Choice

After setting a schedule, write down the topics you are strong and weak in. If you've already taken a data structures and algorithms class, you should have a good idea. Two common topics that people are weak in are recursion or dynamic programming.

Example

Let's say you are weak in recursion. On Leetcode's problem page, set the tag to "recursion". Then sort by difficulty. Pick out around 5-10 problems to work on. For example I have picked out 9 problems, divided into 3 difficulties:

  1. Range Sum of BST (easy)
  2. Sum of All Subset XOR Totals (easy)
  3. Increasing Order Search Tree (easy)
  4. Swap Nodes in Pairs (medium)
  5. Binary Search Tree to Greater Sum Tree (medium)
  6. All Possible Full Binary Trees (medium)
  7. Special Binary String (hard)
  8. Number of Atoms (hard)
  9. Find Minimum Time to Finish All Jobs (hard)

Shedding Light

At this point, you can solve one per day. Resist the temptation to do one after another. If you had trouble with a problem, ask yourself — why exactly did you struggle? Was it the syntax? Unfamiliarity with the data structures required? Or maybe you just didn't know the type of algorithm?

Each problem you do will shed some light on your weaknesses, so you should try to pinpoint areas that need extra work as much as possible. Avoid memorization at all costs. It'll do you no good in the long run especially since it doesn't take very much to change the problem class from one complexity to another with simple constraints.‌

Solution Language

The language you use to solve the problem doesn't matter. Python has generally been recommended but if you want to stand out, use the language the role required in the job description. For example, if the job asks for experienced C++ programmers, then solving the problem using cool STL tricks will help you stand out amongst candidates that used Python.