What’s up everyone! Sam here from Byte-by-Byte.com and in this video I’m gonna show you exactly how to use LeetCode
and solve the problems as effectively as possible so that you’re no longer just
grinding random problems over and over again. And that you’re not forgetting the
problem that you studied like three days later. And if you’re interested in tons
more content on nailing your coding interview, make sure to hit that
Subscribe button and the bell icon and you’ll get notifications every week when
we release brand new videos. I think at this point, we’ve probably all used LeetCode, right. It’s become so synonymous with coding interviews and it’s become such
an important resource that we really do want to make sure that we’re taking
advantage of it. But I think often times people don’t really understand how to
use LeetCode in an effective way. Like you see all these posts of people just
grinding away on LeetCode and you see people studying problems and forgetting
the solutions like a week later. And so obviously something is not working here.
And in this video I want to show you five different strategies that you can
use to actually make sure that when you’re studying LeetCode and when
you’re spending that time, you’re getting the best possible results from the time
that you’re spending, so you’re not wasting any time. You’re not spending
time doing things that are not going to get you the results that you want.
So the first thing that I would recommend that you do when you’re
studying LeetCode is make sure you actually focus on what are going to be
the most relevant problems. There’re so many problems on LeetCode. Right now
I think there are almost 1,200 problems on LeetCode, if not more. And so in your
interview prep, you’re never going to study all those problems. You could… even
if you did go through them all, you’re really not going to remember them. And so
it’s really important that you think about, like, what are the problems that
are most likely to come up in my interview. When we’ve done research, we’ve
found that it’s a pretty small number of problems that come up, like, 90% of the
time. So if you just focus on those problems, you’re gonna get so much more
bang for your buck. And there are a couple places that you can find the most
popular problems on LeetCode and the ones that are most useful. So first of
all, if you have a LeetCode Premium Subscription, you can see here that we
can actually sort by the frequency. And that, I believe, is the frequency of how
often people see the problems in their interviews. So this is a great place to
start. You could do like the top hundred or so. A couple other places that you can
look are we have this top 100 ‘like’ and top 100 most popular questions on LeetCode. And those are available to everybody. So this is a great place to
just look. You can see a list and go and just dig in. And it’s a really great
place where, if you’re not sure where to start or if you just have a few free
minutes, go on the list. Go to the first problem on that list that you haven’t
already done and it’s a great place to just jump in. And finally, I’ll link to
this in the description below, but there’s also this list on TeamBlind of
some of the most popular questions that some people have put together. You can
also just google like ‘LeetCode best problems’ or things like that. There are a
lot of different results where people have compiled their favorites. And also –
shameless plug – we have a 50 questions guide as well over at byte by byte that
you can check out that I would highly encourage you. It’s byte-by-byte.com/50-questions and there is a link in the description for that below as well. So
those are a couple places that you can find some of the most popular questions
that you’re most likely to get asked in your interview, so that you can actually
focus on what is likely to come up and not just do everything. So now I want you
to take a moment and leave a comment below and let me know what is the very
next LeetCode problem that you are gonna solve. What is the one that is next
on list that you are going to solve in your
interview prep? Alright, now that we know which problems we are actually going to
solve, I want to talk a bit about the actual strategy that we should use for
solving them. Because so often I see people just grinding LeetCode ,which
basically means I’m gonna go through the problem, I’m gonna look at it, I’m gonna
try and solve it. If I can’t solve it, I’m gonna look at the answer and then I’m
gonna move on and never revisit this problem again. And so I want to give you
some strategies that you can use to make sure that you’re actually getting the
most of that time. First of all, you want to understand the
goal, right. Understand the goal of what are you trying to accomplish with your
time on LeetCode. What are you trying to accomplish with your time solving these
problems? And the answer is that the goal is not to just look at the problem. The
goal is actually to understand how the problem works so that… not so that you
can solve that problem in the future, but so that you know how to solve
similar problems in the future. And so it’s really important that you focus on
understanding, like, how to solve the problems, rather than focusing on what is
the solution to the problem. So for example, if you get stuck on a problem… If
you’re going through a problem, you want to spend about 30 minutes working on the
problem before you give up. Because if you just give up after five
minutes, you’re never really going to give yourself a chance to even try and
figure it out. But if you do get to the point of you’re
30 minutes into the problem and you can’t figure out what to do and you’re
totally stuck, you can look at the solution. But then you have to understand
what you need to do with that. So when you look at the solution, the goal is not
to say, ‘Oh, this is how it works…’ The goal is to understand the thought process
behind the solution. The goal is to say, ‘I’m looking at the solution and how
could I, in my own head, have come up with this solution? What is the thought
process that would have taken me from that original question to this solution?’
Because if you understand that, then rather than just having to memorize the
solution, if you understand that, you’ll be able to actually then go and solve it
yourself when you see it in the future. So it’s all about understanding an
underlying thought process and not just understanding the solution itself. So the next strategy I would suggest for
you is starting with easy problems and then working your way up. So frequently I
see people start with… they’re like, ‘I’m gonna do a medium problem or a hard
problem…’ and then they get totally demoralized because it’s like they’re
starting above their skill level. And of course we want to push ourselves and we
want to challenge ourselves, but we also want to make sure that we are giving
ourselves the best chance of success. And so if you’re doing stuff that’s too hard,
it’s really easy to give up and it’s really easy to like not make any
progress because you’re just like, ‘I don’t even understand what’s going on
here…’ And so you want to start with the easy problems and work your way up. So I
would encourage you with whatever sort of set of problems you’re starting with,
do the easy problems first, then the medium, then the hard and that way you’re
gonna sort of build up as you go. It’s a really simple tactic, but it’s gonna
allow you to make sure that you are continually pushing yourself to
improve, but you’re not just like jumping way off the deep end and not having that
success. Strategy number four, I think, here…
Strategy… We’ll say strategy number four is to simulate the real world when
you’re in your interview… when you’re practicing for your interview. And this
is so, so important and something that absolutely no one does because it’s work.
But if you put in the work, you’re going to see such better results when you’re
actually in your interview. So the way that this works is that when you’re
solving a LeetCode problem, do not solve the problem in LeetCode. Period. Do not.
You want to do it on a piece of paper or you want to do it on a whiteboard
because that’s what’s going to be similar to what you’re actually doing in
your interview. You want to practice in that environment because
that way you’re going to get used to those other sort of factors that are
like peripheral to the problem itself and you’re going to get good and
actually like working within those parameters. So the way that I would
encourage you to do this is start by working out the problem on a piece of
paper. You want to actually write all the code and code it up and then copy
your code verbatim into LeetCode. So don’t make any changes. It’s gonna be
tempting to see like, ‘Oh, I made a little mistake here; I made a little mistake
there…’ Copy it verbatim in and try and run the code. Because your goal
ultimately is that you should be able to copy your code verbatim, and it should
run. You should have tested your code when you, like, write it by hand and you
should have tested it by hand as well. And so the hope is that you’re gonna put
your code in and it’s just gonna run. But more than likely, there are going to be
issues. And so this is where you can actually learn what are the mistakes
that you tend to make and start to improve on that. So when you type this in,
you’re gonna get some bugs. There’re gonna be some things that just won’t compile.
And then chances are, there’re going to be test cases that are gonna fail as well.
So what you want to do is you want to keep an actual list of all of the
different bugs, all the different syntax errors, all of the different tests that
failed and what the fixes were. And what this is gonna allow you to do is it’s
going to allow you to identify for the future
what are those mistakes that I keep making. And so once you have this list,
now you can go back and the next time you do it say, ‘Okay, well, I’m gonna check
my solution for all of these specific mistakes. Did I put a semicolon
at the end of the each line?’ If you’re coding in JavaScript, you should also
definitely use a linter. You want… because with some of the languages things
are gonna run even if it’s not totally correct
and you want to make sure that you’re writing it as idiomatically as possible.
And so in JavaScript use a linter, with everything else, just make sure
that you are finding all of those little errors and make sure that you’re fixing
them. And then keep that list so that you can review it in the future every time
you do another problem and you’re going to be able to make sure that you are
writing the best possible code when you’re writing by hand. And finally number five… we touched on
this a little bit already but I still think it’s super important. What do you
do when you get stuck solving a LeetCode problem. So it’s so important that you
don’t just like give up and don’t just like go to the solution. You want to make
sure that you’re actually trying to solve the problem. And so again, I would
say spend thirty minutes on the problem. If you get to that 30 minute point and
you still feel like you’re making progress but it’s just going slowly, keep
working at the problem. Only give up on the problem if you spent 30 minutes and
you’re totally stuck. And then when you are stuck, go look at that solution, but
focus on understanding what is it that got me stuck. What was the thought
process that the person who wrote the solution was using and how can I sort of
recreate that for myself? And what you may realize… what you’re
probably gonna realize is one of two things. On the one hand, it’s like there’s
something about the thought process that you missed. You either didn’t think
about ‘X’ thing or, you know, you didn’t have the concept of this. Or you’re gonna
realize that, ‘Oh, I actually was missing like some basic knowledge. Like
maybe it was a sliding window problem and you’ve never done a sliding window
before. So in that case, you want to make sure that you’re then keeping a list of
like what are the topic areas or what are the types of, like, algorithms and
things that I don’t understand. Then you can go study that specifically. But you
really want to make sure that you’re getting as much as you can and getting
as much mileage as you can out of every LeetCode problem possible. If it takes
you an hour or two to go through one problem versus spending an hour or two
skimming five problems and not really understanding them, it’s way better that
you spend all that time on one problem going really deep rather
than spending that time on a bunch of different problems. Alright, so that was
a lot of stuff and I just want to leave you with one last thought, is that it’s
better to make incremental changes than try and do everything at once and then
give up on it. So what I would highly encourage you to do now is to pick one
of these five strategies that we talked about in this video and implement it
today. Just pick one strategy and start with that and then you can continue to
add the other strategies as you go. And so with that, that’s all I
got for you today. Again we have our 50 interview questions guide which is a
great supplement to all of the problems on LeetCode. We have video solutions
there, so I’d highly recommend that you check that out. And if you enjoyed this
video, please give us a like and subscribe and share it with anyone who
you think that this would be useful to. I’d encourage you to check out some of
these videos around me. We have a lot of good stuff on the channel and I look
forward to seeing you guys next week.