Common Coding Interview Mistakes
- Views
- 9.3K
- 9,333
- Outlier
- ×1.0
- Median 9.2K
- Length
- 13:54
- Published
- Jan 7
- Wednesday
- Comments
- 24
- 238 likes
Script
How it's written
- Words
- 2,965
- Words a minute
- 213
- Reading time
- 13 min
- Segments
- 10
The hook
0:00–0:16I really want to like dissect like somebody's like thought process when they're like doing these things because I think it's different for everybody. And that's kind of the side that like a lot of people don't see. They see like a solution and everybody has their own way of taking a solution, understanding it in a way that like makes sense to them.
Structure
I really want to like dissect like somebody's like thought process when they're like doing these things because I think it's different for everybody. And that's kind of the side that like a lot of people don't see. They see like a solution and everybody has their own way of taking a solution, understanding it in a way that like makes sense to them. Like a lot of people will watch like a video, but even the videos don't really capture I think what somebody's actually doing when they're solving a problem. Because even in my case, if I'm explaining a problem, most of the time that's actually not the way I solve it because it's kind of like if I'm explaining like arithmetic, like adding, addition, or whatever, nobody's actually like carrying like certain things in their head. Like you take these certain like I think at least most people take like mental shortcuts without like realizing it. And I would almost say that that's like a very very necessary part. And I think that's why people see like a really hard problem and they're like, "Holy crap, like that's insane. I can't even imagine how somebody could solve something like that. And it's in my opinion analogous to like an instrument. Like I can't imagine how somebody could play like the piano so quickly. But like eventually over time you kind of build that like muscle memory. And I think uh you could use so many analogies even uh like CPUs. They have uh if I recall correctly, they have like dedicated circuits for doing certain like operations because they're so common. I think there's like the inverse square or something that's like really really common in I think game development or other like graphics engines or whatever. I think CPUs, if I'm correct, maybe I'm wrong, but I think they have like a dedicated circuit specifically to calculate like the inverse square root because it's so
Watch from 0:00common. And I think usually that'll happen with people as well. And I think that's what you kind of alluded to where you you solve problems, but you solve problems that are difficult and then eventually you just keep doing that. You build up the like the circuits in your brain or whatever that allow you to like recognize the patterns and solve problems quickly. What do you kind of think about that like uh in your experience? Yeah, I think uh the idea of of having like uh specific shortcuts like you see a pattern and you're like bam segment tree or like uh bam uh like a monotonic stack, you know, something like that. Um you see a problem like the way it's laid out, you like kind of know how it's going to you kind of know how the story is going to end. So yeah, you definitely've got uh like metal shortcuts like that and those are only developed through experience. um you you don't you don't really build it up by reading about it. You you you build it up by doing lots of problems, going through the weeds, uh struggling with it, trying a bunch of other stuff that doesn't work. And then I guess on that topic, you mentioned that a lot of people like like one mistake that some people make is that they'll solve problems that aren't like appropriate for like their difficulty level or something that isn't actually giving them any like benefit. Are there other things that you see people commonly like doing wrong? people are doing problems that are like uh out like far outside their difficulty. Like if they're at a medium level, they're doing hard questions, things like that. Um what other things do I see people doing wrong? Well, what one of the big ones is like giving up too quickly or like letting AI like especially nowadays
Watch from 1:31letting AI just do everything so they don't learn anything. Uh there are ways you can use AI uh nowadays um uh where you can you can ask it to explain like just give me a small hint and then if if you're like stuck for like 15 minutes or so you ask for a small hint and then see if that like mentally like unblocks you and then try it again and uh and if if it doesn't work get another small hint just enough to get you past the rest of the way. So I guess when you were solving problems, what exactly did that look like? Because this is what I think a mistake people make as well. Like what does it mean to solve a problem? Does that mean okay, you couldn't solve it, you looked at the solution and then you tried to understand the solution and maybe you did kind of have like a shallow understanding and then you got accepted on leak code or whatever. And I think I think that's what people look at, right? Okay, I got accepted. You know, it's there's a statistic right there that means I solved problems. Is that what it means to solve a problem? Or does it mean that okay, you had to look at the solution and then you solve the problem and then eventually maybe you come back to that problem a week later and try to solve it without looking at the solution. Does that qualify as a solved problem or like something else? Like what does it actually mean to to practice or to solve a problem? Uh for the record, I never go back to previous problems unless unless maybe somebody on stream requests that I solve that problem and I've previously solved it, but I never look back. Um, I know a lot of people do that. Um, but if you if you derive value from it, great. A lot
Watch from 3:02of people use like to use like the Anky flash card approach where like uh you you'll you'll have a problem and then you you'll solve it and then it'll just show up in another flash card again that that very same problem. So you have to solve it again. So like the spaced repetition thing. Um I personally don't find any value in repeating a problem. Um, but uh to answer your question, what does it mean to actually solve a problem? Well, well, for one, the the easy way is like if you already knew how to solve the problem, like you you type out everything and you get you get the AC done. I mean, you solve it that way. But if you didn't know how to solve the problem, then you have to figure out like what uh you you have to think through it. um or like if if you didn't already know how to solve the problem, you have to think through it and then uh go through like all of your toolbox of uh techniques and tools or whatever and then I mean if you solve it from that toolbox like it didn't immediately come to mind like that you knew how to solve it but uh you dug through your toolbox and you picked out a couple tools and they happen to work great then you solved it that way. um that's a learning experience because like you've learned that now later on in the future if you see a similar problem that can be part of your instant recognition method. But um if you don't if you dug through your toolbox, you couldn't find it, you take a you can take a hint um and then add that to your toolbox and then solve it.
Watch from 4:32Or you can take two hints or three hints or whatever. Um uh but if you need the entire you know if if you've completely given up you need the entire thing um you you read the entire solution uh one thing you you can still do to to salvage some kind of learning out of that is um reading the solution and either trying to type it up yourself or reading the code and trying to copy over the code like just read the code try to memorize roughly what it does and then try to type it out uh from memory. uh so that even if you have to look up the solution um even if you have to look up the whole solution you can get some kind of small learning out of it and uh the more of those little tidbits of you have to mentally fill in the gap you can get out of a problem the better. So like in terms of what qualifies as a solve, yes, technically it's just get an AC, but there are different levels of what you can get out of the problem based on how you approach it, right? Yeah, I think that makes a lot of sense. And now I'm curious about what that looked like for you for the problems you solved. Um, for example, like uh in my case, like if I solved a problem, like in my experience, sometimes I got to problems that like I didn't have a ghost of a chance of getting it right. like I didn't know what the hell a segment tree was. Maybe I could have derived it. Maybe I could have like, you know, you could say whatever. If maybe if I was a math genius, I could have done it even if I could have probably would have taken me hours and if it took me like, you know,
Watch from 6:01an entire day of just banging my head against the wall. Um, I probably would have gotten a lot out of it, but also maybe that's indicative of like the question was too difficult. So, I'm curious like in your experience and and to be honest, that actually was the case a lot of my time. Like I I remember looking at a problem and like I just spent hours and hours even sometimes after looking at the solution I spent hours trying to understand it. So I'm curious in your experience like what did that look like? What was like the longest it took you to like maybe fully understand a problem or to for you to be satisfied with like okay I I kind of get what's going on and maybe I couldn't do it initially but now I do. Oh oh oh the the longest it took me. Okay. Um there was a problem on this actually my first online judge wasn't lead code. It was this thing called sphere online judge. Um there was this problem that okay I was feeling real confident one day and then I went after a problem that um so the way sphere online judge works is they have they have the problem and they won't let you look at solutions uh like other people's like previous solutions and stuff. Uh so like if you don't get it right like you're you're like stuck stuck. Um, but like uh this this problem I think had like two people in in the entirety of Sphere online judges existence that had solved it before. Um, actually I I can give you the code. It's it's called metm pm. Um, and so you can see a bunch of like attempts from 2010 uh from from a
Watch from 7:32guy for like I I tried that problem for a straight month. I tried over optimizing like my C++ code. Um and I was just like not getting anywhere. Um but then later on a code forces GM showed up in my chat and said um told me told me roughly what's up. Um and uh I don't know should I should I like spoil it? Uh yeah, go ahead. Okay. Okay. So it it turn it turned out to be an FFT problem. So that's an example of like I I did I did not know how to use FFT in a competitive programming environment. Yeah. Uh so that that's an example where I I uh I tried I tried so so what what what what are the lyrics? Oh my god. Um but anyway, I got so far. I tried so hard but but in the end it was FFT. Um and I I just didn't know how to use that technique. If I were to do things again from the start uh on that problem, I would uh I would attempt that problem for like maybe a good half an hour to an hour um before like looking up a hint because um one I mean it's it's I mean okay mathematicians are a little bit sadistic or like masochistic that that's the word right. Um they they can they can tolerate a lot of pain and they they like they like the mental pain of like trying to solve a problem. Yeah. um they they they like the mental pain of trying to solve a problem. And so they will be attracted to very difficult problems that look like they're out of reach and
Watch from 9:02like I I think I could get that. I I really think I got a shot at that. Okay, maybe use this technique. Maybe use this other technique. And then you just keep working on it, working on it, working on it, and all of a sudden like six hours have gone by and you're like, I really haven't gotten anywhere on this problem, have I? Um, but yeah, no, it was like that with me in that problem for like a whole month. I had like an exact same kind of experience because I think in terms of like what people can do wrong, uh, people like to anybody watching this, especially if like you're a beginner, you're definitely going to do something wrong. Like don't look for like the perfect way to do it. Sometimes you're going to like spend too much time. Sometimes you're going to not spend enough time and just end up memorizing the solution. And I think it's kind of just about trying to find like a balance and like what works for you. But I would say my biggest problem was that I wasn't willing to like look at a solution or I wasn't willing to do that because I felt like damn like if I don't figure it out myself that I'm just memorizing a formula. I'm just like I have to like derive it. I have to like prove it. I have to do this and and for some problems you can kind of get close like like I think like some problems like alien dictionary it's really hard for a beginner but like it's pretty intuitive. There's nothing super crazy as long as you know like the core graph algorithms behind it. But there are some things at least for me like the monotonic stack and I wasn't solving like an easy monotonic stack problem. It was like one of the harder ones but I just could not like I just felt like it was possible like okay it seems like it's possible that there's a linear solution to this but I can't figure out what the it is and I have never heard of the monotonic stack. I don't know to use it in that
Watch from 10:32way. It's such an unintuitive thing for me even to this day. I think that those are like something about that just knowing that like the ordering of a stack can help you solve a problem unless it's like a really trivial one. It's just so like unintuitive. But once you know the core idea like you can kind of apply it and you know to think of it and you're just like okay I don't really know how to solve this problem. Does a monotonic stack work? you just try to like force it in and you find okay there is a way to to do it and yeah like it's just so frustrating but like you again like if you're just preparing for interviews and trying to do it in a time efficient way like you kind of have to like find the balance somewhere in there and I think the people who do it best are the people willing to like balance that. Yeah. I feel like for time pressure the the biggest thing for time pressure for me um I I feel like you've got to do like you've got to do the lead code contests. Um, I you could have a substitute in the sense that you take a problem and you like set yourself a timer of 20 to 30 minutes or something. Uh but it's really not the same as like being in kind of a global contest where everybody else is kind of doing it under the same time limits and okay prior to AI like being able to solve everything like you could see the leaderboards you could like see how quickly each person solved each thing and like you could al you could also read their solutions to see how like uh one of the one of the most helpful things for me at least for the contests as far as contests are concerned I mean by the time I got good
Watch from 12:03at contests like passing lead code interviews was like essentially trivial. But like for um for the purposes of getting better at contests, one of the uh one of the most useful things I found was looking at a top competitor, how they wrote their code, how they structured things, what kind of templates they used. Um,
Watch from 13:34Full transcript
- 0:00
I really want to like dissect like somebody's like thought process when they're like doing these things because I think it's different for everybody. And that's kind of the side that like a lot of people don't see. They see like a solution and everybody has their own way of taking a solution, understanding it in a way that like makes sense to them. Like a lot of people will watch like a video, but even the videos don't really
- 0:20
capture I think what somebody's actually doing when they're solving a problem. Because even in my case, if I'm explaining a problem, most of the time that's actually not the way I solve it because it's kind of like if I'm explaining like arithmetic, like adding, addition, or whatever, nobody's actually like carrying like certain things in their head. Like you take these certain
- 0:40
like I think at least most people take like mental shortcuts without like realizing it. And I would almost say that that's like a very very necessary part. And I think that's why people see like a really hard problem and they're like, "Holy crap, like that's insane. I can't even imagine how somebody could solve something like that. And it's in my opinion analogous to like an instrument. Like I can't imagine how somebody could play like the piano so quickly. But like eventually over time
- 1:02
you kind of build that like muscle memory. And I think uh you could use so many analogies even uh like CPUs. They have uh if I recall correctly, they have like dedicated circuits for doing certain like operations because they're so common. I think there's like the inverse square or something that's like really really common in I think game development or other like graphics
- 1:23
engines or whatever. I think CPUs, if I'm correct, maybe I'm wrong, but I think they have like a dedicated circuit specifically to calculate like the inverse square root because it's so common. And I think usually that'll happen with people as well. And I think that's what you kind of alluded to where you you solve problems, but you solve problems that are difficult and then eventually you just keep doing that. You build up the like the circuits in your
- 1:43
brain or whatever that allow you to like recognize the patterns and solve problems quickly. What do you kind of think about that like uh in your experience? Yeah, I think uh the idea of of having like uh specific shortcuts like you see a pattern and you're like bam segment tree or like uh bam uh like a monotonic stack, you know, something
- 2:05
like that. Um you see a problem like the way it's laid out, you like kind of know how it's going to you kind of know how the story is going to end. So yeah, you definitely've got uh like metal shortcuts like that and those are only developed through experience. um you you don't you don't really build it up by reading about it. You you you build it up by doing lots of problems, going
- 2:25
through the weeds, uh struggling with it, trying a bunch of other stuff that doesn't work. And then I guess on that topic, you mentioned that a lot of people like like one mistake that some people make is that they'll solve problems that aren't like appropriate for like their difficulty level or something that isn't actually giving them any like benefit. Are there other things that you see people commonly like doing wrong? people are
- 2:46
doing problems that are like uh out like far outside their difficulty. Like if they're at a medium level, they're doing hard questions, things like that. Um what other things do I see people doing wrong? Well, what one of the big ones is like giving up too quickly or like letting AI like especially nowadays letting AI just do everything so they don't learn anything. Uh there are ways
- 3:06
you can use AI uh nowadays um uh where you can you can ask it to explain like just give me a small hint and then if if you're like stuck for like 15 minutes or so you ask for a small hint and then see if that like mentally like unblocks you and then try it again and uh and if if it doesn't work get another small hint
- 3:27
just enough to get you past the rest of the way. So I guess when you were solving problems, what exactly did that look like? Because this is what I think a mistake people make as well. Like what does it mean to solve a problem? Does that mean okay, you couldn't solve it, you looked at the solution and then you tried to understand the solution and
- 3:47
maybe you did kind of have like a shallow understanding and then you got accepted on leak code or whatever. And I think I think that's what people look at, right? Okay, I got accepted. You know, it's there's a statistic right there that means I solved problems. Is that what it means to solve a problem? Or does it mean that okay, you had to look at the solution and then you solve the problem and then eventually maybe you come back to that problem a week later and try to solve it without
- 4:07
looking at the solution. Does that qualify as a solved problem or like something else? Like what does it actually mean to to practice or to solve a problem? Uh for the record, I never go back to previous problems unless unless maybe somebody on stream requests that I solve that problem and I've previously solved it, but I never look back. Um, I know a lot of people do that. Um, but if you if
- 4:30
you derive value from it, great. A lot of people use like to use like the Anky flash card approach where like uh you you'll you'll have a problem and then you you'll solve it and then it'll just show up in another flash card again that that very same problem. So you have to solve it again. So like the spaced repetition thing. Um I personally don't find any value in repeating a problem.
- 4:51
Um, but uh to answer your question, what does it mean to actually solve a problem? Well, well, for one, the the easy way is like if you already knew how to solve the problem, like you you type out everything and you get you get the AC done. I mean, you solve it that way. But if you didn't know how to solve the problem, then you have to figure out
- 5:12
like what uh you you have to think through it. um or like if if you didn't already know how to solve the problem, you have to think through it and then uh go through like all of your toolbox of uh techniques and tools or whatever and then I mean if you solve it from that toolbox like it didn't immediately come to mind like that you knew how to solve
- 5:33
it but uh you dug through your toolbox and you picked out a couple tools and they happen to work great then you solved it that way. um that's a learning experience because like you've learned that now later on in the future if you see a similar problem that can be part of your instant recognition method. But um if you don't if you dug through your toolbox, you couldn't find it, you take
- 5:54
a you can take a hint um and then add that to your toolbox and then solve it. Or you can take two hints or three hints or whatever. Um uh but if you need the entire you know if if you've completely given up you need the entire thing um you you read the entire solution uh one thing you you
- 6:15
can still do to to salvage some kind of learning out of that is um reading the solution and either trying to type it up yourself or reading the code and trying to copy over the code like just read the code try to memorize roughly what it does and then try to type it out uh from memory. uh so that even if you have to look up the solution um even if you have
- 6:37
to look up the whole solution you can get some kind of small learning out of it and uh the more of those little tidbits of you have to mentally fill in the gap you can get out of a problem the better. So like in terms of what qualifies as a solve, yes, technically it's just get an AC, but there are different levels of what you can get out
- 6:58
of the problem based on how you approach it, right? Yeah, I think that makes a lot of sense. And now I'm curious about what that looked like for you for the problems you solved. Um, for example, like uh in my case, like if I solved a problem, like in my experience, sometimes I got to problems that like I didn't have a ghost of a chance of getting it right. like I didn't know
- 7:19
what the hell a segment tree was. Maybe I could have derived it. Maybe I could have like, you know, you could say whatever. If maybe if I was a math genius, I could have done it even if I could have probably would have taken me hours and if it took me like, you know, an entire day of just banging my head against the wall. Um, I probably would have gotten a lot out of it, but also maybe that's indicative of like the
- 7:39
question was too difficult. So, I'm curious like in your experience and and to be honest, that actually was the case a lot of my time. Like I I remember looking at a problem and like I just spent hours and hours even sometimes after looking at the solution I spent hours trying to understand it. So I'm curious in your experience like what did that look like? What was like the longest it took you to like maybe fully understand a problem or to for you to be satisfied with like okay I I kind of get
- 8:01
what's going on and maybe I couldn't do it initially but now I do. Oh oh oh the the longest it took me. Okay. Um there was a problem on this actually my first online judge wasn't lead code. It was this thing called sphere online judge. Um there was this problem that okay I was feeling real confident one day and then I went after a problem that um so the way sphere
- 8:23
online judge works is they have they have the problem and they won't let you look at solutions uh like other people's like previous solutions and stuff. Uh so like if you don't get it right like you're you're like stuck stuck. Um, but like uh this this problem I think had like two people in in the entirety of
- 8:46
Sphere online judges existence that had solved it before. Um, actually I I can give you the code. It's it's called metm pm. Um, and so you can see a bunch of like attempts from 2010 uh from from a guy for like I I tried that problem for a straight month. I tried over
- 9:07
optimizing like my C++ code. Um and I was just like not getting anywhere. Um but then later on a code forces GM showed up in my chat and said um told me told me roughly what's up. Um and uh I don't know should I should I like spoil it? Uh yeah, go ahead.
- 9:27
Okay. Okay. So it it turn it turned out to be an FFT problem. So that's an example of like I I did I did not know how to use FFT in a competitive programming environment. Yeah. Uh so that that's an example where I I uh I tried I tried so so what what what what are the lyrics? Oh my god. Um but anyway, I got so far. I tried so hard
- 9:47
but but in the end it was FFT. Um and I I just didn't know how to use that technique. If I were to do things again from the start uh on that problem, I would uh I would attempt that problem for like maybe a good half an hour to an hour um before like looking up a hint because um one I mean it's it's I mean
- 10:09
okay mathematicians are a little bit sadistic or like masochistic that that's the word right. Um they they can they can tolerate a lot of pain and they they like they like the mental pain of like trying to solve a problem. Yeah. um they they they like the mental pain of trying to solve a problem. And so they will be attracted to very difficult problems
- 10:30
that look like they're out of reach and like I I think I could get that. I I really think I got a shot at that. Okay, maybe use this technique. Maybe use this other technique. And then you just keep working on it, working on it, working on it, and all of a sudden like six hours have gone by and you're like, I really haven't gotten anywhere on this problem, have I? Um, but yeah, no, it was like
- 10:51
that with me in that problem for like a whole month. I had like an exact same kind of experience because I think in terms of like what people can do wrong, uh, people like to anybody watching this, especially if like you're a beginner, you're definitely going to do something wrong. Like don't look for like the perfect way to do it. Sometimes you're going to like spend too much time. Sometimes you're going to not spend enough time and just end up memorizing the solution. And I think it's kind of
- 11:11
just about trying to find like a balance and like what works for you. But I would say my biggest problem was that I wasn't willing to like look at a solution or I wasn't willing to do that because I felt like damn like if I don't figure it out myself that I'm just memorizing a formula. I'm just like I have to like derive it. I have to like prove it. I have to do this and and for some problems you can kind of get close like
- 11:33
like I think like some problems like alien dictionary it's really hard for a beginner but like it's pretty intuitive. There's nothing super crazy as long as you know like the core graph algorithms behind it. But there are some things at least for me like the monotonic stack and I wasn't solving like an easy monotonic stack problem. It was like one of the harder ones but I just could not like I just felt like it was possible
- 11:54
like okay it seems like it's possible that there's a linear solution to this but I can't figure out what the it is and I have never heard of the monotonic stack. I don't know to use it in that way. It's such an unintuitive thing for me even to this day. I think that those are like something about that just knowing that like the ordering of a stack can help you solve a problem unless it's like a really trivial one.
- 12:14
It's just so like unintuitive. But once you know the core idea like you can kind of apply it and you know to think of it and you're just like okay I don't really know how to solve this problem. Does a monotonic stack work? you just try to like force it in and you find okay there is a way to to do it and yeah like it's just so frustrating but like you again
- 12:35
like if you're just preparing for interviews and trying to do it in a time efficient way like you kind of have to like find the balance somewhere in there and I think the people who do it best are the people willing to like balance that. Yeah. I feel like for time pressure the the biggest thing for time pressure for me um I I feel like you've got to do like you've got to do the lead code contests. Um, I you could have a
- 12:58
substitute in the sense that you take a problem and you like set yourself a timer of 20 to 30 minutes or something. Uh but it's really not the same as like being in kind of a global contest where everybody else is kind of doing it under the same time limits and okay prior to AI like being able to solve everything like you could see the leaderboards you
- 13:18
could like see how quickly each person solved each thing and like you could al you could also read their solutions to see how like uh one of the one of the most helpful things for me at least for the contests as far as contests are concerned I mean by the time I got good at contests like passing lead code interviews was like essentially trivial. But like for um for the purposes of
- 13:41
getting better at contests, one of the uh one of the most useful things I found was looking at a top competitor, how they wrote their code, how they structured things, what kind of templates they used. Um,
Description
🚀 https://neetcode.io/yt - A better way to prepare for Coding Interviews
Full episode
Spotify: https://open.spotify.com/episode/1J5q...
Youtube: • Interviews, Competitive Programming & Vibe...
Youtube Music: • NeetCode Podcast
🧑💼 LinkedIn: / navdeep-singh-3aaa14161
🐦 Twitter: / neetcode1
⭐ BLIND-75 PLAYLIST: • Two Sum - Leetcode 1 - HashMap - Python
#neetcode #leetcode #python




