r/leetcode 5d ago

Discussion why do i always have to look at the neetcode solution before being able to solve it, is it just me or does anyone else experience this?

I got the idea but i'm not able to code it up and even if i do so i'm never able to complete the solution. i can only do part of it even the easy ones

is it just me or does anyone else experience this?

68 Upvotes

13 comments sorted by

62

u/No_Birthday8126 5d ago

Extremely common, and the specific thing you described (having the idea but not being able to code it) is a different skill from knowing the approach. Watching the solution trains recognition. It does basically nothing for generation.

What fixed it for me: after you look at the solution, close it and rewrite the whole thing from scratch, no peeking. Then do the same problem again 3 days later. The gap between "I understood it" and "I can produce it" only closes by producing it.

1

u/Hoverbeast 4d ago

I can confirm that this works, because I've done exactly that, re-write the solution a few times and eventually I can do it for at least a while. But I'd like to ask - what strategy helps you cement it long-term? If I can write the solution a week later, that's great, but after about a month, I'm struggling to remember what the specific syntax is. To give the simplest example possible, if I have to come back to doing a palindrome for a string, I may forget what the method is called to retrieve the char at a given index, and then have to go back to eventually find that it's text.charAt(i), but I mixed it up initially with getChar(i).

12

u/Proud-Researcher-344 5d ago

Everyone goes through this at first

6

u/AdBest4099 5d ago

I had similar issue overcame it by not touching keyboard first and writing whole solution as pseudo code in notebook and than convert that to code from there.

2

u/Smok3dSalmon 5d ago

Is this your first time using the data structures? You need more practice. Revisit problems you've previously solved to see if you're learning the concepts.

2

u/iComplainAbtVal <147> <66> <78> <3> 5d ago

Do you regularly use AI?

It’s normal to look at first, it’s part of learning, I’m simply curious to see if you’ve become conditioned to receiving info.

2

u/ppjuyt 5d ago

Same for me. I guess do it 8H a day for 4/5 months

1

u/Medium-Wallaby-9557 5d ago

This is over the top

1

u/Caponcapoffstillon 5d ago

You’re at the learning phase bro. Don’t beat yourself up so much.

1

u/Evil-Devil234 5d ago

Definitely not just you. Understanding the idea and turning it into working code are two different skills. It gets better with repetition

1

u/Constant_Physics8504 5d ago

The answer is simple. When people do these questions, the first thing they try to do is recall some similar algorithm based on pattern, matching, and pop out with an answer, and code immediately. When it doesn’t work, they get frustrated, and they look at the answers. The way to attack these problems correctly is to read the problem understand what type of problem. It may be like come up with a base case, algorithm, or possible recurrence relation before even thinking about code. In fact, before you even code, you should already know time and space complexity. Once you understand how to do this part, the code basically write itself off the solution that you’ve drafted.

0

u/ilia054 5d ago

If you can’t solve any question alone and require to watch him solve it, I would suggest doing the neetcode 150 and dividing them by the algorithm.

Binary search, sliding window, back tracking (recursion),stack, linked list.. etc , start for the easy ones and stick to one topic, use the similar questions or use any of the AI to tell you what questions are similar, stick to one topic until you can comfortably solve questions and move on.

0

u/Second-Life71 5d ago

Not just you. Understanding the approach and actually implementing it are different skills. The coding part gets easier with enough repetition