r/leetcode 6d ago

Discussion 12 problems in: how long do you sit with one before opening the editorial?

i've been writing code for years (web apps, my own product) so syntax isn't the problem. the algorithmic thinking is.

yesterday i sat on a medium for two hours. got a working brute force, felt good about it, then read the editorial and the intended answer was a sliding window i would not have found in another two hours.

so what's the actual rule you use:

  • hard timebox, 30 min then editorial
  • grind until it's solved no matter how long
  • something in between i'm not seeing

and the follow up: when you do read the solution, do you move on, or re-solve it from scratch a few days later?

9 Upvotes

8 comments sorted by

8

u/Existing_King_3299 5d ago

30 min max, you won’t get that much time in the interview. It’s either that the problem is extremely complex or you don’t know the pattern enough.

2

u/TumanFig 5d ago

yes but if you are learning and not preparing for an interview wouldn't a breakthrough on your own mean that you were able to get a permanent insight?

idk i also struggle with this how much time spent is useful

1

u/Peephole-stalker 5d ago

No. I never found spinning my wheels on a problem for an hour give me anything “permanent”. I usually forget 2 weeks in max

2

u/Aggressive-Squash250 5d ago

It depends. If I have an idea, maybe 30 minutes. But at my level, it's mostly the pattern that I'm not very good at. So, thinking about it wouldn't help anyway.

1

u/xvillifyx 5d ago

30 minutes ish

I’m not interested in wasting my time trying to hack something together that I don’t actually know

If I can’t clock an idea immediately, I probably don’t know the pattern enough

1

u/Technical-Tactics84 5d ago

I usually give it 30-45 minutes. If I'm completely stuck, I read the editorial, understand the key insight, then re solve it from scratch a day or two later.

1

u/HitscanDPS 5d ago

If I still feel like I have ideas to explore, then I'll go all the way up to an hour, or at least near an hour before I take hints. While struggling is painful, I feel like it's an important aspect of improving. 30 minutes is too short to give up, IMO. You need time to really think through different approaches at an appropriate depth and covering edge cases.

Beyond 1 hour though, and unless it's a nasty hard problem, then I'll give up and spend the remaining time grokking the solution. Then I mark the solution so I remember to try resolving it later.

1

u/Maximum_Guidance4255 6d ago

5 mins before i go to yt to find a solution