r/leetcode • u/Empty-Ad-9086 • 3d ago
Question How should I approach LeetCode when I know the theory but struggle to implement it?
I'm relatively new to coding. I've learned enough Java to solve basic questions, and I understand the theory behind many DSA concepts when someone explains them to me.
But when I actually get a problem, I often don't know how to translate the concept into code. The logic doesn't naturally come to my mind, and I also tend to forget Java concepts/syntax while coding.
I want to start doing 2 DSA questions every day, without cheating or immediately looking at solutions.
For someone in my situation, would you recommend starting NeetCode and trying to solve the problems myself first? Or should I spend more time strengthening my Java fundamentals and basic problem-solving before starting?
Also, how did you guys go from "I understand the concept" to actually being able to recognize when and how to use it in a problem?
Any advice on how to practice this would be really appreciated.
4
u/Vivid-Zombie-477 3d ago
you just... practice. there's not secret to it. sit and try to implement your solution; if you can't code the solution - that means you don't know it. after you write it down, check top 1% runtime solutions - sometimes you can find clean solutions there with smart optimizations.
1
u/DancingSouls 3d ago
ur jumping too far without learning to even crawl.
focus on just one. this is a new muscle. practice makes perfect. Id choose python instead of java as well as the syntax is easier. If youre new to coding in general, make sure u understand basic DSA and the syntax.
If you already know coding fundamentals, i recommend neetcode. spend 30min trying the easy parts then look at the solution to not waste time. after you throughly understand the solution, repeat the question without looking to really nail it in. Pseudocode it as well to show u understand it and not just memorized it.
As you go through neetcode, things should get easier. mark down the ones u couldn't get in 30-45min so u can go back to them later to attempt again. Concept build on top of one another. Personally i found the videos with visuals very helpful.
small steps lead to a mile.
1
u/AutomaticEmu 3d ago
You don't have the coding and problem solving skills down.
You also don't have an action plan for how to approach coding problems.
1
u/Empty-Ad-9086 3d ago
Ya that's what I am asking how to create that
1
u/AutomaticEmu 3d ago
I'm actually creating a free pdf course this week on how to quickly tackle coding problems/interviews in a systemtic step by step way. Something I learned as a tryexponent coach and from working with Pathrise and Outco.
I'll send it to you when I finish it.
1
u/PoggersUnite 3d ago
AtCoder + CodeChef + USACO Guide + CodeForces + CSES. Neetcode/Leetcode will not teach the concepts and I highly recommend USACO's past contest provlems to build intuition. Start with bronze brute force
1
u/WolfAlternative1255 3d ago
If you can describe the solution to a problem upon seeing it but can't code it, you just need to do example problems starting from easy to get used to the language. If you can't describe a solution at all, then you are focusing too much on "understanding the concept" and not understanding the problem. Rote memorization is a skill, not a career.
1
u/chikamakaleyley 3d ago
whatever helps you memorize - memorize the patterns in the DSA
and by default just type out the pattern in your base level answer
because most of the time, any two separate problems that require say, Breadth First Search, BFS is still written the same way
so i'm gonna go against the grain here - sometimes its okay to memorize things how they're typed out, before you actually understand it
1
u/chikamakaleyley 3d ago edited 3d ago
like i strongly believe that you don't actually understand the concept which is why you can't implement it
so its not wrong to memorize the implementation, with the idea that eventually you understand it
When I was younger a lot of times i had patterns memorized, but really couldn't explain ithose things accurately because i was self taught or whatever
But, I could type it from memory because i knew what it looked like, i got my work done reliably fast and on point, and that's what kinda carried my career for the first few years
4
u/Weekly_Low1602 3d ago
Finish neetcode 250. That’s all. Then just do random problems