Red-Green-Code

Deliberate practice techniques for software developers

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

LeetCode Tip 32: Minimize the Time You Spend on Each Problem

By Duncan Smith Aug 16 0

LeetCode 2023

When you’re working on a LeetCode problem, there is always a solution available, either the official solution or a solution from the discussion forums. So, as you’re working on your own solution, you always have the option of getting help. Your study strategy, therefore, needs to tell you how long to work on a problem before looking at a solution.

It’s easy to see why immediately looking at the solution is a bad idea. The only way to learn how to solve coding problems is by solving coding problems. Just reading about them doesn’t help. So we can rule out 0 minutes as the right amount of time to work on a problem.

Another approach is never looking at the solution until you have solved the problem on your own. If you can’t solve a problem, just move on to another one and return when you have more experience. This approach sounds reasonable. Every problem requires specific background knowledge, and until you have that background, you can’t make a proper attempt. So it’s better to save the problem for when you’re prepared for it.

The problem with this approach is the trial and error that it requires. Since you never look at the solution, you don’t know what skills you need to solve the problem, which means you don’t know when you’re ready to make another attempt. You could come back to the problem and find that you’re still missing a critical skill. If, rather than never looking at the solution, you plan to look at the solution only when you get stuck, you’re just moving the trial and error into the future. When you look at the solution, it will reveal what skills you need, but not which problems to use to practice them.

To get around these problems, you can use the techniques of problem lists and spaced repetition. Rather than approaching each problem as a test that tells you if you’re smart enough to solve it, look at it as a stepping stone to learn the next sub-skill on the way to mastering a topic.

Using this approach, you can minimize the time you spend on each problem. If you follow a problem list, you can solve problems in an efficient order, with each problem leading to the next one. If you get stuck on a problem after spending a reasonable amount of time (on the order of 1-2 hours at the most), read the solution to see what you’re missing. Then add the problem to your spaced repetition list and try it again in a day or two. Using this process, you can ensure that you’re always working on the right skills and solving problems at the right level.

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