How I would learn Leetcode if I could start over

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
how would I grind elak code if I could start all over again I'm going to try to make some points that are honestly pretty simple but I think you probably haven't heard most of them before and quickly before I start someone always comments leak code is useless save your time doing real development blah blah blah it's completely true I've never encouraged people to grind leak code I've only like told them how to do it it's true that most full stack jobs don't require knowledge of data structures and algorithms I would still personally argue that DSA knowledge is still useful at least understanding like the core algorithms but you know what else is true you probably went to school for 20 years of your life learning a lot of things that you aren't going to use at your full-time job that doesn't mean learning those things was useless from my perspective if spending a couple months grinding leak code can get me a really high-paying job then honestly I don't care how useless it is because leak code literally changed my life even if I didn't create like the YouTube channels the fact that I was able to get a job at Google just because I grinded leak code seems pretty worthwhile to me and I think it's a life-changing job for most people but how do you actually get good at leak code let me explain when I first started doing leak code problems I realized this is the most academically difficult thing I've ever done in my life I had taken AP Calculus and physics and a bunch of really difficult things in high school and in college honestly college for me was a little bit easier than high school I remember everyone would always say you know high school is hard but wait until you get to College college is going to be really hard that's when you're going to have to learn how to study and improve your study habits and everything for me I think when I took my first programming class in college that's when I struggled a little bit but after that at least for me I went to a pretty average college it was relatively easy I'm not going to lie but you know what was difficult when I started hitting leak code problems I wish somebody had told me you know leak code is not easy this is the hardest thing you're probably going to do to get a job it's going to be harder than all of your classes that you've ever taken when I took my first programming class like I said I struggled a little bit at the beginning so for me programming is actually harder than these other technical subjects but now I tell myself I was just in that like machine learning phase where I was just taking in a bunch of new data understanding how to use it and then eventually I got familiar with it and then I was good I wish I could say the same thing about leak code every time you think you're good at it you see a crazy problem and it just destroys your confidence it's completely different than anything you've ever seen before so what is so different about leak code than everything else is it really harder than everything like when I was doing it I just thought damn I guess I'm just not smart enough I thought I was a genius my whole life doing everything so easily getting A's whenever I wanted to but damn this thing I just can't do it I don't think it's about intelligence at all believe it or not it's about systems it's about processes it's about methodology how you're doing it at least that's my opinion and I'm going to try to convince you why first let me show you how I learned leak code when I first started you have a problem a hard problem median of two sorted arrays it's the fourth leak code problem imagine how many people came across this problem and just wanted to jump out the window after of course most people can't solve it so what do you do well back in the day leak code didn't really have articles and editorials and even this one is payal so you end up going to the solutions tab it used to be called the discuss tab nowadays if you go here you'll click one of these and man you'll see this beautiful explanation look at this this guy's explaining it with hints with everything doesn't have any pictures in here but sometimes they even have pictures you know it's reasonable to be able to understand one of these Solutions you can see this one was recent right 2023 back in my day though we didn't have that this is what we used we used these Solutions and also Lee 2115 if you've heard of him but look at this like look at this solution first of all just look at it crazy solution and not much of an explanation given okay the second one is I guess a little more reasonable I don't know even though the third one is definitely a little bit more reasonable there's not really much of an explanation you go down here you don't see much of an explanation at least back in the old day like 2019 when I was doing it everybody's just asking can you actually explain it and nobody did okay the best you'd get is like five comments here so I know I make videos on these problems and sometimes I don't do a perfect job either but you have to realize that it's tough love okay I can't explain every little detail in a 20-minute video I can do the best to give you like the intuition of why a solution works even that in my opinion is a lot easier than how I learned this is how I learned I would look at these Solutions you know for hours and hours try to figure out why they worked and finally when I did I would try to make like a video explanation for it thankfully now we do have a lot better resources but even then leak code is still not easy why isn't it easy so if I'm arguing that leak code actually isn't much more difficult than math or physics or some other highly technical subject that you have learned before why does it feel so much different and I think one big reason is the process the methodology the way that you learned these things versus the way that you're trying to learn this let me just kind of rewind take you back through time and remind you how did you learn math when you were a kid you probably first learned how to count like 1 2 3 4 and just learned the base 10 digit system and then you probably learned bigger digit numbers 100 110 234 something like that and you were able to then start adding numbers together 1 plus 2 and then bigger digit numbers 3 4 five one two three do you think if I successfully explain to a child how to solve this problem and they are able to do it they are able to take these digits and add them together and get that big number and then I make it more complicated and I teach them how to carry a number to do like more complex addition maybe subtraction if I show them how to do that just a single time or maybe even several times in the same day and then maybe a week later a month later I show them the same thing and they don't practice in between that week or month I give them a similar problem do you really think they'd be able to solve it probably not unless they're really really smart the point I'm making is you could teach somebody how to do something difficult they do it a single time they think they understand how to do it but if a bunch of time goes by you're probably not going to be able to do it again kids learn the same way adults do with repetition right so that's a pretty simple answer repetition so why don't more people do it I mean it just sounds so simple why don't more people do repetition when it comes to leak code let me kind of explain the classic problem people make when they solve leak code problems let's say they're solving a medium binary search problem and I bet you most people who try to solve a like medium level binary search problem they're probably not even super good at like basic binary search but okay they try to do it it takes them probably some cognitive energy to even Implement basic binary search you know if it takes you 10 minutes to implement basic binary search that's a problem you shouldn't even be attempting medium problems if it takes you you know 10 minutes to figure out that this number is 234 why are you doing addition you don't even know what this number represents right you got to get really really good at the basics before you kind of take steps beyond that but okay just contining you get to a medium binary search question you realize that it's a binary search question but you still can't solve it all you have is your basic binary search algorithm implemented then you look at the solution it takes you maybe 1 hour to understand the solution but you're able to do it you write your code you kind of really exercise your brain muscles you write it and now you're done for the day then you continue solving leak code problems maybe a month later you solve another medium binary search question you're not able to solve it you look at the solution it takes you some time to figure out the solution once you realize it's binary search you feel bad you realize it's similar to a problem you've already solved but you weren't able to figure it out again why not because you tricked yourself you think you understand the solution and maybe you did for a very short time but that didn't really sink in and it's not your fault when you're learning something that's genuinely difficult like if you're reading the solution to a problem it's difficult and you think you understood it which you might have but it didn't sink in so of course you need repetition it's such a simple answer isn't it just practice but then why isn't anybody doing it this is how you learn pretty much everything in life when you learn how to read it takes practice why don't people do it when it comes to leak code I don't know but let's be honest I made the same mistake until I realized this I thought like huh I did so well in high school I did so well in math and physics so why am I so bad at leak code because the way I'm practicing it isn't enough leak code is difficult it's difficult like math and physics but it's not more difficult you could not teach somebody how to count and add numbers and divide numbers numers in a relatively short time without practicing so now let me try to give more concrete advice on how to practice how to actually do repetition because even that isn't as straightforward as you might expect first of all there are certain core algorithms algorithms like binary search DFS depth for search breath for search sliding window and a bunch of other kind of core algorithms that I talk a lot about on this channel as well as like you can check a lot of this stuff out on n code. but my personal advice to you would be get really really good at these Basics practice them a lot you can do that at the same time that you're solving leak code problems or you can do it before you start solving leak code problems but you want to get good at it and I promise you it won't take you that long the Target that most people set when they're solving leak code problems is I want to be able to look at a Le code problem and solve it quickly that in my opinion is the wrong target you should get really good at just core algorithms that should be your target at least that should be your first Target and binary search it's a very short algorithm what is it like less than 10 lines of code I think every computer science student learns it maybe the first time you do it it'll take you like 30 minutes or an hour to like fully understand it okay the next time you implement it should probably take you like half that 15 minutes the third time you do it I bet it'll take you like 10 minutes and the fourth time probably like 8 minutes eventually you should get to a point where you can imp M this in less than 5 minutes I could probably do it in like 30 seconds to be honest cuz it's not that much code you could say I memorized it or you could say I deeply understand it you could say whatever you want but the point is I could implement it very quickly so now when I get to a medium difficulty leak code problem the binary search aspect of that problem is Trivial to me it's like 1 two three like number systems it takes me no cognitive energy to focus on implementing binary search or understanding why it works understanding why it's efficient any of that doesn't take me any time to get to this level suppose it just takes you like implementing binary search five times and I probably implemented it you know dozens of times but there is like diminishing returns if you can Implement binary search 10 times in the period of like a week or a month you can probably get just as good at it as I am some of these other algorithms are probably a little more difficult DFS BFS but the same idea can be applied to those Implement these five times 10 times whatever it'll probably take you a few hours to do that let's say say 4 hours to implement it like 10 times now you don't understand you have such a big Advantage when you look at leak code problems now like you really don't understand it until you've experienced it when you've been in my shoes many of you who are good at leak code probably know the feeling these things are so trivial to you that Medium problems can also be a lot easier now you actually have the brain capacity to focus on how you can take these algorithms and actually apply them to a medium problem which takes a lot of energy you're not kind of juggling two things at once you're not trying to re-remember how do I Implement BFS and also how do I apply it to this difficult problem you're not doing that I don't know why when somebody solves a leak code problem and then they look at the solution they feel bad about that but they look at the solution they're able to solve it why not solve the same problem the next day why not do you think you're going to lose anything by doing that I guess it takes time but if that problem is fresh in your mind it might not take you more than like 15 minutes so why not do it you're reinforcing something that is good I promise you anybody who's really really good at leak code or a really good competitive programmer this stuff is literally like ABCs to them you have to do that to get good you can call it cheating you can call it memorizing but that's just how it is and I know for a lot of people this isn't fun but in my opinion it's pretty fun being able to go into an interview and be able to solve it and get you know a high-paying job as a result even if you agree with everything I've said so far there is some more Nuance to this leak code is more difficult than just what I've talked about here some problems are definitely more difficult than just taking something and applying like a core algorithm to that problem I'm specifically talking about hard problems and even some medium problems I think the next level of getting good at this stuff is similar to what I'm talking about repetition practicing in a smart way but I think the next level is asking the question why does something work most people think math is just memorizing memorizing numbers formulas you have some formula fals ma in physics once you know what the force is the mass is the acceleration is you just take those values you plug them in and then you get some value as a result that's what people think math is what math really is is being able to argue why the math works in the first place AKA proofs right you might have taken a discret math class in college or some other class where you had to do math proofs and this is kind of the second compon component to leak code problems in my opinion the more complicated component you might have looked at a leak code solution or watched one of my videos even though the algorithm made sense it might have been an algorithm you're familiar with you still didn't fully understand why it worked and the why is so important because if you want to be able to solve a problem for the first time you have to really understand why the repetition I talked about before will only take you so far what I'm getting at is it's not just about being able to quickly write out the DFS algorithm or BFS algorithm from scratch it's about understanding exactly why it works I try my best in my videos to explain this but it's not always easy unless I want to make like an hour long video my advice to you for figuring this stuff out is just spending some time thinking about it I know that's kind of an obvious answer but it's the only answer nobody can force you to do it no matter how well of a resource you find whether it's an article or a video nobody can go in your brain and actually force you to think about why something works and you do need a little bit of curiosity for that for example there is an algorithm called two pointers it's applied in many cases to like binary search you need two pointers and in sliding window you need two pointers and there's a condition in problems where you'll have something like while the left pointer is less than the right pointer this is the condition sometimes though you'll have the while left is less than or equal to right and I've had some people ask me the question how do you know whether it's this or whether it's less than or equal and they try to memorize it but I don't think it's worth memorizing I think you have to really look at the context of the problem and figure out why that's the case the easiest thing would be to come up with some examples I think people watch my videos sometimes because I'll have like an example and walk through it why can't you you do that by yourself why can't you bring out a pen and paper and just walk through an example by yourself is it because you're lazy because I promise you I wouldn't have gotten good if I didn't do this drawing and I only do the drawing for my videos when I'm practicing something by myself I'm using pen and paper so if you're the type of person when you get stuck you just kind of go blank you just stare at your screen you're just thinking in your head try to do something else try to type out some notes some comments as you're trying to code up a solution or you know use pen and paper if not doing that you're missing out I promise you anybody who's really really smart only got good at it by practicing by thinking of creative examples by thinking of edge cases that would maybe break a solution or maybe would reinforce a solution and explain why exactly that solution works I think if there's anything that you have learned from this video it's that a lot of the things you did as a kid and maybe you stopped doing as an adult were very very useful to you like taking handwritten notes explaining your thought process repetition even boring repetition even doing something so many times to the point where it just gets so boring that's kind of what math class was as a kid those things are useful like the structure that is forced on you when you're a kid is very very useful and I think having too much Freedom as an adult is not when you have like eight hours in a day it's easy to procrastinate but when you're a kid you have like one hour with this class a second hour in Spanish class or whatever and that kind of you know structure is pretty useful full when it comes to learning there's a reason why everybody does it all around the world
Info
Channel: NeetCodeIO
Views: 314,985
Rating: undefined out of 5
Keywords:
Id: aHZW7TuY_yo
Channel Id: undefined
Length: 18min 3sec (1083 seconds)
Published: Sun May 26 2024
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.