Red-Green-Code

Deliberate practice techniques for software developers

  • Home
  • About
  • Contact
  • Project 462
  • CP FAQ
  • Newsletter

LeetCode Tip 50: In Case of Emergency, Read This Tip

By Duncan Smith Dec 20 0

LeetCode 2023

What if you carefully implement Tips 1 through 49, and they just aren’t working? You study your model problems, but when you repeat them after a week or two, you can’t remember the relevant details. You learn a LeetCode topic in depth, but when you try to solve a new Medium problem in that topic, it seems to require different skills from the ones you learned when you were practicing relevant model problems.

In other words, LeetCode can be hard, even when you’re working on a problem labeled Medium.

Next week, I’ll review all the tips from this year. But in this last tip, let’s focus on the core of the model problem and solution system, in case you are finding that it isn’t performing as advertised.

First, it’s good to notice that something isn’t working. Although practice is the only way to improve, it doesn’t guarantee improvement. Consistent, focused practice can fail to produce results. Observing that results aren’t happening is the first step to adjusting your practice to make it work better. Tips 1-49 provide a lot of ideas about what kind of practice works best in general, but it’s up to each person to adjust their practice until it works for them.

And eventually it will work. LeetCode topics are designed to be learned. They are based on the curriculum that computer science students study before they get to the hard problems of research or industry. It’s true that most students don’t learn them to the level required to excel in a coding interview. And it may take much longer than you want to get to that point. But learning them is a step-by-step process with no magic or luck required. (Getting a job at any particular company does require some luck, but that’s the nature of coding interviews).

Let’s distill the model problem and solution process down to two elements.

Element 1: Learn a smaller concept

At its core, the system described in Tips 1-49 is based on model problems and model solutions. But a problem may be too big to learn all at once, even after you have practiced it several times. Fortunately, every problem is made up of smaller parts. To practice effectively, figure out which of those parts is giving you trouble. Suppose you’re learning binary search and it isn’t clicking when you try to use it for Medium problems. Maybe you don’t completely understand the loop condition: given how the loop is set up, why does the function always terminate, and when should you use lo <= hi vs. lo < hi. Rather than trying to understand these elements using the full binary search problem, write a smaller program that focuses only on the loop condition. Or use math and diagrams to analyze it, if that’s what makes more sense to you.

By carving up a LeetCode problem into smaller and smaller pieces, you can always reach the point where the concept you’re learning is small enough that you can completely understand it, internalize it, and remember it indefinitely. It does take time to deconstruct and learn problems this way, and it takes a different amount of time for each person depending on their innate ability and their background. But it eventually works.

Element 2: Spaced repetition

Once you find a section of a problem that’s small enough to learn, learning it comes down to spaced repetition. No matter how well you study and understand a concept, or how small that concept is, you won’t completely know it until you can reproduce it over days, weeks, and months. The spaced repetition process helps you learn things and also shows that you know them. It is compatible with the strengths and weaknesses of our brain.

This year, I’m publishing a series of tips for effective LeetCode practice. To read the tips in order, start with A Project for 2023.

Categories: LeetCode

Prev
Next

Stay in the Know

I'm trying out the latest learning techniques on software development concepts, and writing about what works best. Sound interesting? Subscribe to my free newsletter to keep up to date. Learn More
Unsubscribing is easy, and I'll keep your email address private.

Getting Started

Are you new here? Check out my review posts for a tour of the archives:

  • 2023 in Review: 50 LeetCode Tips
  • 2022 in Review: Content Bots
  • 2021 in Review: Thoughts on Solving Programming Puzzles
  • Lessons from the 2020 LeetCode Monthly Challenges
  • 2019 in Review
  • Competitive Programming Frequently Asked Questions: 2018 In Review
  • What I Learned Working On Time Tortoise in 2017
  • 2016 in Review
  • 2015 in Review
  • 2015 Summer Review

Archives

Recent Posts

  • Do Coding Bots Mean the End of Coding Interviews? December 31, 2024
  • Another Project for 2024 May 8, 2024
  • Dynamic Programming Wrap-Up May 1, 2024
  • LeetCode 91: Decode Ways April 24, 2024
  • LeetCode 70: Climbing Stairs April 17, 2024
  • LeetCode 221: Maximal Square April 10, 2024
  • Using Dynamic Programming for Maximum Product Subarray April 3, 2024
  • LeetCode 62: Unique Paths March 27, 2024
  • LeetCode 416: Partition Equal Subset Sum March 20, 2024
  • LeetCode 1143: Longest Common Subsequence March 13, 2024
Red-Green-Code
  • Home
  • About
  • Contact
  • Project 462
  • CP FAQ
  • Newsletter
Copyright © 2025 Duncan Smith