(Monday) June 06, 2022

5 Steps to Grind LeetCode Effectively with Spaced Repetition and Deliberate Exercise

As software engineers, we dream of landing a job at a big tech company. Of course, we must go through the interview process, and the coding interview is one of them. However some of us only have a minor improvement after solving numerous of question. This article shares how to improve steadily by utilizing spaced reptition and deliberate exercise.

📌

Confucius: Learning without thinking is useless. Thinking without learning is dangerous.

You won't improve no matter how many questions you have solved without thinking about the solution but keep checking the others' solutions.

Foreword

As software engineers, we dream of landing a job at a big tech company. Of course, we must go through the interview process, and the coding interview is one of them. Therefore, LeetCode has become one of the go-to platforms for learning and practicing data structure and algorithms. Many software engineers realize they only make little progress after solving hundreds or thousands of questions.

We have always been told by those experienced software engineers who are good at problem-solving to practice and solve more questions to get good at it. That’s true, but they forget to share with us, or we never ask how they practice. Usually, one would share the spaced repetition and deliberate exercise.

Mistakes I have made

Two of them are critical factors, but we have to be more specific about using them to grind LeetCode effectively. One of the gurus told me I had been using the wrong method to practice all the while.

Below are three mistakes I had made,

  1. I was solving the questions randomly, especially the daily question. That defeats the deliberate purpose since I am still unfamiliar with many algorithms.
  2. I never use a timer to time the question when solving the question.
  3. I never read back the review of the questions I had done.

5 Steps to Improve Steadily

Based on the three mistakes I made, they propose the five steps below,

  1. Solve one question with a specific topic daily
    We should solve a question with a specific tag daily, especially the weak topic, until you are comfortable with the type of questions.

    🖇️

    Assume that I am weak in the depth-first search algorithm. Therefore I should keep practicing it until getting handy with it.

  2. Prepare a timer to time the time
    You can better understand how comfortable you are solving the question with a timer. Give yourself a time of 30 ~ 45 minutes to solve the question.
    There are three ways to solve the question when you are stuck by going to the discussion section.
    You should only go to the next step if you’re at every 10 minutes. However, the more steps you go, the more unfamiliar you are with the topic.

    Below is the sample solution for Two Sum

    • Read the Data Structure or Algorithms used to solve the question from the list.

      Idea Reference
    • Click into the list and read the idea of how to solve the question by using the data structure and algorithms.

      Idea Reference
    • Read the implemented code.

      Idea Reference

    When you can solve multiple easy questions within 30 ~ 45 minutes, you can increase the difficulty to medium.

  3. Review the question and solution by the end of the day/next day
    Constantly reviewing and understanding the solution helps improve your logical thinking, and you might also discover some new and exciting solutions yet practical and effective.

    Doing this also helps you summarize and recognize the regularity or patterns.

    Below are some of the points you can ask yourself while reviewing,

    • Where and why do you stuck? It might because lack of knowledge of using specific algorithms, data structure or not fully understanding the question?
    • How to improve the algorithms? Maybe you are writing a brute force solution and perhaps can improve it?
    • How to better avoid bugs? Do you have more than two submissions that failed not because of your answer but syntax error?
    • How to improve your coding style for better understanding? Perhaps you should avoid using a and b as your variable name. You are not doing competitive programming but writing the code for your interviewer to understand.
  4. Understand your strength and weakness
    You might gain self-awareness about your strengths and weaknesses after reviewing the question and solution.
    Please write it down and check back once in a while.

    🖇️

    Remember to review your strength because keep checking your weaknesses will demotivate you.

    Example: You managed to solve the question within 20 minutes. Write down what you have done, like the thought process, what have you done to unstuck and etc.

  5. Read the review periodically
    It is essential to check back your review on the following day, weekly, biweekly or monthly basis.