Red-Green-Code

Deliberate practice techniques for software developers

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

LeetCode Tip 33: Prioritize Understanding

By Duncan Smith Aug 23 0

LeetCode 2023

When you’re working on a challenging LeetCode problem, it’s easy to spend a lot of time on it. As long as you can keep thinking of ideas to try, you can keep adjusting your code to see if it improves your results. If your solution fails on large test cases, you can try to optimize it. If it passes most test cases, you can use the first failed case for testing. Hours can go by as you work on your last bug.

As I wrote in the previous tip, this isn’t a good use of study time. Rather than trying to fix every bug, it’s best to stop after an hour or two and look up what you’re missing. Then you can focus your efforts on learning that missing piece.

But while it’s good to minimize how much time you spend on a problem the first time around, multiple subsequent repetitions aren’t necessarily something to avoid. When you find a high-quality problem that covers topics you want to learn, there’s nothing wrong with putting time into it. The key is to spend time in the right areas.

When you’re repeating a problem for the second or third time, your goal should be the same as it was the first time around. Not to see if you can solve the problem with no help, but rather to figure out what skills this problem requires and make sure you learn them thoroughly. During subsequent repetitions, you have the advantage that you have already seen the solution once, so you are reinforcing skills rather than seeing them for the first time. But you can still get stuck. If that happens, consult your model solution to get back on track.

Since your model solution gives you a simple process to get unstuck, you don’t have to spend any more time than necessary when repeating a problem. But what isn’t as predictable is how long it will take you to completely learn a problem. You may find parts of the solution to be challenging to understand, even after you have solved the problem a few times. You may need to read up on math or algorithms. But understanding is the key to learning a solution for the long term. So it’s worth spending as much time as necessary to build this understanding.

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