How I would learn Leetcode if I could start over
Summary
TLDRThe speaker emphasizes the value of mastering data structures and algorithms through LeetCode challenges, despite their difficulty compared to traditional academic subjects. They argue that while most full-stack jobs might not require this knowledge, it is still beneficial and can lead to high-paying positions. The speaker shares their personal journey and offers advice on how to effectively learn and practice coding problems, stressing the importance of repetition, understanding core algorithms, and the 'why' behind solutions. They also highlight the need for curiosity and critical thinking to truly grasp complex problems, advocating for a structured approach to learning similar to that experienced in school.
Takeaways
- 🚫 The speaker does not encourage grinding LeetCode but acknowledges its value in improving coding skills and securing high-paying jobs.
- 📚 Despite most full stack jobs not requiring knowledge of data structures and algorithms (DSA), having a foundational understanding is still beneficial.
- 💡 The speaker argues that learning DSA is similar to learning other subjects in school that may not be directly applicable to one's job but are still valuable.
- 🔄 LeetCode problems can be more challenging than traditional academic subjects due to their complexity and the need for a systematic approach to solve them.
- 🤯 The speaker emphasizes that LeetCode is difficult and can be frustrating, but it's not about intelligence; it's about the learning process and methodology.
- 📈 The speaker learned LeetCode by studying solutions for hours, trying to understand why they worked, and then attempting to explain them in video form.
- 🔑 The process of learning LeetCode involves understanding core algorithms and practicing them repeatedly to build familiarity and speed.
- 🎯 The speaker suggests that the goal should be to master core algorithms rather than just solving LeetCode problems quickly.
- 🧠 Understanding 'why' an algorithm works is crucial for being able to apply it effectively to different problems, which requires deep thinking and curiosity.
- 📝 The speaker recommends using pen and paper to work through examples and think about edge cases to reinforce understanding.
- 🔄 Repetition is key in learning LeetCode, similar to how children learn basic math through repeated practice.
Q & A
Why does the speaker believe that grinding LeetCode is worthwhile despite its difficulty?
-The speaker believes that grinding LeetCode is worthwhile because it can lead to high-paying jobs and has personally changed their life, including securing a job at Google.
What does the speaker suggest is the main difference between LeetCode problems and other academic challenges they've faced?
-The speaker suggests that the main difference is not the level of difficulty, but rather the process and methodology required to solve LeetCode problems, which is more about systems and repetition than raw intelligence.
What is the speaker's opinion on the necessity of understanding data structures and algorithms for most full stack jobs?
-The speaker acknowledges that most full stack jobs do not require knowledge of data structures and algorithms, but they still argue that having a basic understanding is useful.
Why does the speaker emphasize the importance of repetition when learning from LeetCode?
-The speaker emphasizes repetition because it is a fundamental way humans learn, and it is particularly important for mastering the core algorithms and problem-solving techniques required for LeetCode.
What is the speaker's advice for someone who is struggling with LeetCode problems?
-The speaker advises to focus on mastering core algorithms like binary search, DFS, BFS, and sliding window through repetition and practice, rather than jumping into complex problems.
How does the speaker compare the learning process of LeetCode to learning math or physics?
-The speaker compares the learning process by stating that while LeetCode is difficult like math and physics, it is not more difficult, and the key to mastering it is through the same process of repetition used in learning math or physics.
What is the speaker's view on the common mistake people make when solving LeetCode problems?
-The speaker believes the common mistake is not practicing repetition. People often think they understand a solution after seeing it once, but without repetition, they are unable to recall and apply the solution effectively later.
What is the speaker's recommendation for the initial target when solving LeetCode problems?
-The speaker recommends that the initial target should be to get really good at core algorithms and not necessarily to solve LeetCode problems quickly.
Why does the speaker suggest that understanding 'why' an algorithm works is important for solving LeetCode problems?
-The speaker suggests that understanding 'why' an algorithm works is important because it allows for a deeper comprehension that goes beyond memorization, enabling one to apply algorithms effectively to a variety of problems.
What role does the speaker believe curiosity plays in truly mastering LeetCode problems?
-The speaker believes that curiosity is essential for mastering LeetCode problems because it drives the learner to ask questions, think about why solutions work, and explore creative examples and edge cases.
How does the speaker feel about the structure and discipline imposed during childhood learning and its application to adult learning?
-The speaker feels that the structure and discipline imposed during childhood learning, such as repetition and note-taking, are very useful and should be applied to adult learning as well, as they help in mastering complex subjects like LeetCode problems.
Outlines
📚 Embracing the Challenge of LeetCode
The speaker starts by addressing the common misconception that LeetCode is useless for real-world development. They argue that while full-stack jobs may not require deep knowledge of data structures and algorithms, understanding core algorithms is beneficial. The speaker shares their personal experience, stating that LeetCode significantly improved their career prospects, even leading to a job at Google. They acknowledge the difficulty of LeetCode problems, comparing it to academic challenges faced in high school and college, and emphasize the importance of persistence and learning from solutions to improve.
🧠 The Difficulty of LeetCode and the Importance of Repetition
The speaker delves into why LeetCode problems can feel more challenging than traditional academic subjects, attributing it to the learning process and methodology. They reminisce about their own learning journey, highlighting the lack of comprehensive resources in the past and the difficulty of understanding complex solutions without proper explanations. The speaker stresses the importance of repetition in learning, drawing parallels to how children learn basic math. They argue that the lack of practice and repetition is a common mistake made by those attempting LeetCode problems, and suggest that revisiting and re-solving problems is key to mastering the concepts.
🔍 Mastering Core Algorithms Through Repetition
Building on the concept of repetition, the speaker advises focusing on mastering core algorithms like binary search, DFS, BFS, and sliding window. They emphasize that becoming proficient in these algorithms should be the initial goal, rather than quickly solving complex LeetCode problems. The speaker shares their personal strategy of implementing algorithms multiple times to reduce the cognitive load when facing medium difficulty problems. They argue that this approach allows for more mental capacity to focus on applying algorithms to problem-solving, rather than recalling how to implement them.
🤔 The 'Why' Behind Algorithm Efficiency and Problem Solving
The speaker discusses the importance of not just knowing how to implement algorithms, but also understanding why they work and why they are efficient. They suggest that this deeper understanding is crucial for tackling more complex problems and for being able to solve problems for the first time. The speaker encourages learners to spend time pondering the 'why' behind solutions, to think creatively about examples and edge cases, and to practice explaining their thought process. They emphasize that this approach, combined with the structured learning habits often instilled during childhood, is essential for truly mastering LeetCode problems.
Mindmap
Keywords
💡LeetCode
💡Data Structures and Algorithms (DSA)
💡Full Stack Jobs
💡Academic Difficulty
💡Methodology
💡Repetition
💡Core Algorithms
💡Binary Search
💡Problem Solving
💡Competitive Programming
💡Understanding 'Why'
Highlights
The speaker emphasizes that while LeetCode is challenging, it is not necessarily more difficult than other technical subjects, but requires a different learning approach.
LeetCode problems are academically difficult and can be harder than college classes, but the speaker argues that the difficulty is due to the learning process rather than intelligence.
The speaker shares personal experience, stating that grinding LeetCode changed their life and helped them secure a job at Google.
The importance of understanding core algorithms is highlighted, as they form the basis for solving more complex LeetCode problems.
The speaker discusses the lack of good resources in the past for understanding LeetCode solutions and the difficulty of learning from them.
A comparison is made between learning LeetCode and learning math or physics, emphasizing the need for a systematic approach to problem-solving.
The concept of repetition in learning is introduced as a key strategy for mastering LeetCode problems, similar to how children learn math.
The speaker explains that understanding solutions to LeetCode problems is not enough; one must practice and internalize the knowledge through repetition.
The importance of practicing basic algorithms like binary search until they can be implemented quickly and without much thought is discussed.
The speaker argues that the goal should not be to solve LeetCode problems quickly, but to deeply understand and be able to implement core algorithms efficiently.
The process of learning is compared to carrying numbers in addition, where understanding the process is more important than just getting the answer.
The speaker suggests that the difficulty in re-solving LeetCode problems stems from not truly internalizing the solution the first time.
The value of re-solving LeetCode problems to reinforce learning is highlighted, comparing it to the way children learn through repetition.
The speaker provides a detailed example of how to practice binary search and other algorithms repeatedly to build proficiency.
The importance of not just memorizing algorithms but understanding why they work is emphasized for truly mastering LeetCode problems.
The speaker encourages the use of pen and paper to work through examples and understand the 'why' behind algorithms and solutions.
The video concludes with the speaker reflecting on the usefulness of childhood learning strategies like note-taking, repetition, and structured learning for mastering LeetCode.
Transcripts
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
Weitere ähnliche Videos ansehen
I solved 541 Leetcode problems. But you need only 150.
5 advanced coding projects to expose you to complex concepts
How to Start Leetcode (as a beginner)
How to improve LeetCode Problem Solving in 5 min | 10X Better at Leetcode
How To Get Placement After Wasting 2-3 Years of Engineering? SDE Roadmap for College Students
My Brain after 569 Leetcode Problems
5.0 / 5 (0 votes)