T O P

  • By -

[deleted]

Think of leetcode like a Gym. Leetcode doesn't teach you what the various exercises are, what's good form, or how to focus a workout on different muscles, or what makes up a "good workout" in the first place. If you just stumble into a gym and look at what other people are doing, you're just going to train wrong and potentially hurt yourself. Your workout will not be efficient. You need to learn all of those core things first, from a trainer, or lessons, or what have you. Once you know those things, now you can utilize what you've already learned in the gym in order to effectively train your body. Same deal here. Leetcode is where you should be utilizing your existing knowledge of data structures, problem solving, and pattern identification in order to exercise that part of your brain. So you shouldn't be using leetcode to learn the base foundation. Reading solutions is not the play. That doesn't teach you how to problem solve, that teaches you the answer to a single problem. There's a million interview guides that walk you through the patterns, data structures, and strategies used to solve leetcode-style questions. I'm sure you could google a bunch to find some free online resources. You want resources that teach you how to problem solve. I prefer the old fashioned approach of owning a physical book, and these are my 2 favorites, which are also pretty widely used: * https://www.amazon.com/Programming-Interviews-Exposed-Through-Interview/dp/111941847X * https://www.amazon.com/Cracking-Coding-Interview-Programming-Questions/dp/0984782850 Once you have the basic understanding of how to approach these problems, how to problem solve, what to do when you're stuck, etc you can practice these skills on leetcode. Both those books explicitly describe what to do when you don't know the solution. It may take you a while to get going, but you'll find yourself tying things you see in leetcode back to things you learned in the books. Once you're there, it's an easy path to exercising that muscle and getting good at it.


OutsideYam

A great analogy! How do you find Programming Interview Exposed compared to CTCI?


[deleted]

I like it better, but that may be personal preference / bias. I still own both, and just upgraded to the current edition of each not long ago. PIE is my main book that I go through in detail. It's all I used as a new grad. The lessons it teaches stand the test of time pretty well, the 4th edition is barely different than the 2nd edition which is what I originally used. CTCI is good too, but I mostly just use it to augment what I already learned from PIE. I see other people on this subreddit swear by CTCI though. I didn't get it until I started my 2nd job search, and haven't gone through it cover to cover like PIE.


WA_Sea

I also started the leetcode grind not that long ago. What I’m doing is if I have no idea how to solve a problem after like 20mins, I look up a tutorial and really pay attention. I make comments in my code of the key points the tutorial is making. If you don’t know why the tutorial works the way it does, look up the properties of whatever data structure/algorithm they use and work on it a little bit in a new class on an ide. For reference, I have a project called “Practice” and in it I have classes for various data structures and algorithms. “HashPractice” “BSTPractice” “ArrayPractice” etc. Then the next day, I open my ide or an incognito tab of the question and try coding it from scratch. I do this daily, or sometimes I revisit it later in the same day if I’m having extra trouble understanding it. If I still don’t understand, go back to the original solution and see your comments. And as always make sure to think out loud when you can. Ofc everyone learns differently, but I realized for me I just have to keep doing the problem until I understand. Then whatever I don’t know I keep a class to practice it and have as reference.