How to Solve ANY LeetCode Problem (Step-by-Step)

แชร์
ฝัง
  • เผยแพร่เมื่อ 23 พ.ย. 2024

ความคิดเห็น • 147

  • @Codebagel
    @Codebagel  6 หลายเดือนก่อน +36

    Link to the free flowchart I used in this video:
    algo.monster/flowchart

  • @alex0917lfo
    @alex0917lfo 6 หลายเดือนก่อน +829

    At the first day of Leetcode , to be honest I felt I should give up. But 1 questions per day , 1 years later , I can pass 70% of easy and 40% medium. I even get an offer by passing 3 Leetcode questions with big bank company. So my suggestion is keep practicing Leetcode like you playing a game!!

    • @vrajpatel9259
      @vrajpatel9259 6 หลายเดือนก่อน +25

      hey, i want to ask you wether you did all of the questions on leetcode by you own without any help or you tried and when you were not able to solve it than you referred to any yt video? i am doing leetcode so i am not able to solve the questions ... i try to solve one question for 1 hr or more and than i refer to yt video. is this good ? any suggestions? Thanks

    • @alex0917lfo
      @alex0917lfo 6 หลายเดือนก่อน

      @@vrajpatel9259 Sure. Since you and my past self have no idea how to play the Leetcode game. Once you have no idea how to do it or don't understand the question within 10 mins , just look for the answer. There is no shame to look at it. The way I still doing it is look at the approach , and use that approach to create your own code.

    • @Mlakshman-w9k
      @Mlakshman-w9k 5 หลายเดือนก่อน

      ​​@@vrajpatel9259hey we are on the same page. But you know that's the way of getting learn from mistakes. Keep it on mind where we struck, why does it happens every time? Try 30-40 mins max for any level of question even though can't trick the solution then try to approach other's intuition and code, then try a dry run on your own.. That's where I found my solution. Keep it up buddy... Have a nice day

    • @dynamiteSoul2324
      @dynamiteSoul2324 5 หลายเดือนก่อน +9

      Same question as above

    • @bavnitsingh23
      @bavnitsingh23 5 หลายเดือนก่อน +19

      Yes buddy , think solution for max an hour
      If it's not clicking than you can see solution
      But after that don't forget to revisit the question after some intervals

  • @anirudh6635
    @anirudh6635 6 หลายเดือนก่อน +203

    If problem solving is your hobby then leetcode is a great place to be at.

  • @GuRuGeorge03
    @GuRuGeorge03 หลายเดือนก่อน +10

    I once got the tip to write down a few cases by hand and then let my brain first do the work, if it can come up with the expected output. if yes, then it means my brain does know an actual algorithm that works, we just need to make it conscious. So first we try to follow what our brain did in simple english, after that we break down the simple english into atomic steps that can be written as code. Once you've done that, you almost always have the optimal algorithm, since our brains are actually genius at this stuff.
    It's only really hard when you can't even explain an algorithm in simple english that will produce the correct output, then it's truly about finding and solving a base case first and working your way up to more compllicated cases.

  • @CommDao
    @CommDao 6 หลายเดือนก่อน +192

    The feeling after starting to learn sort methods: everything is sort!

    • @Codebagel
      @Codebagel  6 หลายเดือนก่อน +24

      Sort is OP

  • @Website_TV_1
    @Website_TV_1 2 หลายเดือนก่อน +10

    Wow, this video is a game-changer! I’ve been struggling with LeetCode problems for a while, but the step-by-step approach you provided made everything so much clearer. The explanation of how to break down the problem and tackle it methodically is exactly what I needed. Thank you for simplifying a process that can feel overwhelming! 🙌

  • @adesai1000
    @adesai1000 4 หลายเดือนก่อน +9

    This feels super helpful, I used to feed discouraged to do DSA cause I used to think I knew how to solve it but wasn't able to code it. This helped me realized it is more than that

  • @incognitohacks4850
    @incognitohacks4850 6 หลายเดือนก่อน +19

    Finally getting serious about coding and this is really eye opening. Started revising and learning about algorithms to get a strong foundation. Thanks for the video

    • @Codebagel
      @Codebagel  6 หลายเดือนก่อน +2

      Great idea! Algorithms make up so much of coding, it’s super important to know the fundamentals.

    • @Randomshorts-r7u
      @Randomshorts-r7u 2 หลายเดือนก่อน

      @@Codebagel What if there are not easy for me that what can I do to learn more...

  • @lisaw7074
    @lisaw7074 3 หลายเดือนก่อน +7

    I just found your channel today and have watched a few of your videos. They are some of the best that I've ever seen when it comes to Leetcode prep with clear instructions and helpful tips. Thanks you so much for sharing these!

  • @yunagarnetsan
    @yunagarnetsan 4 หลายเดือนก่อน +19

    I have a competition this Saturday and I've been asked to practice from leetcode. Let me tell you, I'm only a highschool student. The 'easy' question from leetcode take me a whole 30 mins to come up with an algorithm. I was told that I would be asked questions from medium and hard difficulties. With only 3 days left, I'm not sure of how much I would be able to prepare.

    • @Praveen_C11
      @Praveen_C11 3 หลายเดือนก่อน +4

      Leetcode at highschool??, damn!!!

    • @yunagarnetsan
      @yunagarnetsan 3 หลายเดือนก่อน +18

      @@Praveen_C11 The competition is over, and I managed to get a speed of 15 mins/easy and 25 mins/medium before he competition. Turns out that the organisers were just exaggerating. All the questions were from easy and I managed to get second place. The team that got first just had twice the members as our team.

    • @dineshbh3837
      @dineshbh3837 3 หลายเดือนก่อน

      ​@@Praveen_C11 ikr, i wish I learned code when I was in my dad's balls 💀

    • @hectortelloc
      @hectortelloc 2 หลายเดือนก่อน +3

      @@yunagarnetsan Congrats, and happy to hear your follow up.

  • @RohaanKhalid-pz9iu
    @RohaanKhalid-pz9iu 6 หลายเดือนก่อน +34

    One of the best videos I have watched! Especially going through a problem using the flowchart.

    • @Codebagel
      @Codebagel  6 หลายเดือนก่อน +7

      Thanks so much! Walking through problems with a flowchart is a really systematic way to approach problems, and something I think engineering-minded people really benefit from.

  • @Websitedr
    @Websitedr 4 หลายเดือนก่อน +3

    I like the flowchart which makes more sense on how to systematically figure out which algorithm to use.

  • @redfinance3403
    @redfinance3403 5 หลายเดือนก่อน +28

    That flowchart is genius!

    • @pretoasted
      @pretoasted 8 วันที่ผ่านมา

      Visual stuff like that flowchart is a reason why I loved programming in LabView.
      When debugging you can literally see values changing on 'nodes'/functions, traveling over connections/wires on their way to the next node/function/loop/etc. You can see immediately where issues are as values turn bad and address it right away. I'm sure there are some great examples on YT.
      For what it was meant to do, it did/does it amazingly... but it by far is not something you want to use in projects unrelated to it's focus; Lab Automation.

  • @homerlol9058
    @homerlol9058 6 หลายเดือนก่อน +8

    That flowchart seems extremely useful

    • @Codebagel
      @Codebagel  6 หลายเดือนก่อน +2

      The flow chart is amazing 👌

  • @vulpritprooze
    @vulpritprooze 3 หลายเดือนก่อน +2

    Sh1t, we literally skipped data structures and algorithms last year in my 2nd year at college. We had the subject but we weren't even taught about it (we basically hovered over linked lists and big O notation the entire semester!). I thought it wasn't important and thought how easy the subject was. Turns out I missed a lot! Now it's time to study hard 😢

  • @ttt69420
    @ttt69420 4 หลายเดือนก่อน +3

    The problem people have with these questions is that they try or think they need to invent this algorithm (extremely difficult). When in reality the question is merely testng your almost rote knowledge of an already existing solution.
    a truly unique answer requires a truly unique puzzle, and you just arent going to get that. These sites are learning tools not MENSA entrance exams.

  • @rahulshendre7089
    @rahulshendre7089 หลายเดือนก่อน

    thanks a lot man, 7/10/24
    Simply the problem
    Pattern recognition
    Implementation (pseudocode)
    Code
    Debug

  • @valentinrafael9201
    @valentinrafael9201 5 หลายเดือนก่อน +2

    Perfect practice makes perfect indeed.

  • @unlucky-777
    @unlucky-777 2 หลายเดือนก่อน +1

    It just 1 question per day, trust the progress and believe to yourself

  • @electrode8773
    @electrode8773 5 หลายเดือนก่อน +2

    Keep it up brother...I was one of those subscribers when you had started this channel..Its inspiring to see you grow..❤❤

    • @Codebagel
      @Codebagel  5 หลายเดือนก่อน +1

      Thank you so much! I appreciate that you’ve been here since the start, hopefully I can keep making content that you can enjoy!

  • @aniver987
    @aniver987 5 หลายเดือนก่อน +2

    U think you can make another video of what to learn before leetcoding

  • @Julio-re8em
    @Julio-re8em 2 หลายเดือนก่อน +1

    idk this video kind of confused me a bit but thank you nonetheless for your guidance

  • @timthegreatone
    @timthegreatone หลายเดือนก่อน +1

    I'll come back one year later to this comment and be grateful I did not give up. Thanks for this video. Today is day 1

  • @Mubashir7933
    @Mubashir7933 5 หลายเดือนก่อน +4

    Maybe I'm dumb but what if I didn't understand question, what should I do?

  • @kav04
    @kav04 2 หลายเดือนก่อน

    Example of how to identify a pattern using Ad's website even makes it more vague and complicated

  • @akshaychavan5511
    @akshaychavan5511 6 หลายเดือนก่อน +6

    Everytime I wonder, why is this channel so underrated? 🤔

    • @Codebagel
      @Codebagel  6 หลายเดือนก่อน +1

      Haha thank you! Hopefully it won’t be for long 🫣

  • @0986rashmi
    @0986rashmi 5 หลายเดือนก่อน +2

    Am a big fan of algo monster easy to follow those templates

    • @sameerroshan9542
      @sameerroshan9542 หลายเดือนก่อน

      even if you learn the template how do you solve the problems algomonster gives you. I go through their articles but still find the problems they give us to solve very difficult.

  • @Amuzeraa
    @Amuzeraa 6 หลายเดือนก่อน +5

    Thank you so much this really helps 😊

    • @Codebagel
      @Codebagel  6 หลายเดือนก่อน

      Thanks for watching!

  • @abhinavprabhakar455
    @abhinavprabhakar455 5 หลายเดือนก่อน +3

    Awesome! This video was very helpful. ❤

  • @Joseph-uz2ry
    @Joseph-uz2ry 6 หลายเดือนก่อน +2

    God bless you. This is so clutch

    • @Codebagel
      @Codebagel  6 หลายเดือนก่อน

      Thank you!

  • @Richa_cute
    @Richa_cute 5 หลายเดือนก่อน +1

    So far I have only completed less than 20 problems. Will get back to this comment when I’ve reached a century. 😊
    I know one doesn’t need to solve that many but I’ll taking a safety net so that I can also practice same kinda problems.

  • @harshdiwan9283
    @harshdiwan9283 6 หลายเดือนก่อน +4

    Hi , I have done the topics except dynamic programming and solve around 180 problems but still not able to build logic. Should i leave dsa ? Can you suggest me what should i do ?

    • @Codebagel
      @Codebagel  6 หลายเดือนก่อน

      Hi! What areas do you find you struggle with the most? Is it recognizing the pattern? Is it knowing what to code?

    • @harshdiwan9283
      @harshdiwan9283 6 หลายเดือนก่อน

      @@Codebagel both. Sometimes know the approach but not able to convert it into code.

    • @BlessingAwodeyi
      @BlessingAwodeyi 6 หลายเดือนก่อน

      I'm facing the same problem

    • @neetaspirant901
      @neetaspirant901 5 หลายเดือนก่อน

      Solve recursion problems

  • @bbmeireles
    @bbmeireles 5 หลายเดือนก่อน +1

    Nice tips. Very thanks.

  • @Sulerhy
    @Sulerhy 5 หลายเดือนก่อน +31

    I stoped video at :"My friends cracked FAANG with less than 100 solved LC problems"

    • @takeuchi5760
      @takeuchi5760 5 หลายเดือนก่อน +19

      If you keep refusing learning opportunities at every disagreement in opinion with the pretense that the teacher is unqualified or not suited, you will learn way less than someone who tries to learn regardless of some shortcomings in the teacher.
      I agree that the 100 problems thing is unrealistic but the video still has a lot of value.

    • @gnaneswarilolugu2323
      @gnaneswarilolugu2323 4 หลายเดือนก่อน +1

      That's a stretch but video itself is good.

    • @electric-lemonade
      @electric-lemonade 2 หลายเดือนก่อน +6

      I know people at FAANG who have solved less than 70 problems. If you're fixated on the no. of problems, you're not looking at the right way

    • @NihongoWakannai
      @NihongoWakannai หลายเดือนก่อน

      @@takeuchi5760 How is it unrealistic? More problems doesn't make you better, you just need to know the data structures and algorithms. Doing less problems and focusing really hard on actually studying and reading up on why that solution is the way that it is will be way more educational.

    • @takeuchi5760
      @takeuchi5760 หลายเดือนก่อน

      @@NihongoWakannai And did I say just focus on the number of problems? Solving a problem for me means trying hard to solve it, thinking of different approaches, if it's still not clear, then taking hints/solutions, understanding it bit by bit, then resolving it by yourself to confirm you understand it.
      So, when I say 100 problems is unrealistic, I'm obviously including the "focusing really hard on studying" aspect. Interviews in most competitive markets aren't easy enough that you can get by with just knowing the basics of each topic (which is the max you can cover in 100 questions).

  • @FaberLSH
    @FaberLSH 4 หลายเดือนก่อน

    Thank you! but where is the wordList? I'm trying to run this code but I don't know what is the begin and the end word.

  • @Mahamudul_Hasan_Sami
    @Mahamudul_Hasan_Sami 24 วันที่ผ่านมา

    Can i code with JavaScript?

  • @doitwithghausiya2870
    @doitwithghausiya2870 5 หลายเดือนก่อน

    this is by far the nicest video I have ever watched.

  • @haniissa1990
    @haniissa1990 5 หลายเดือนก่อน

    I want to be sure , in 1:57 you try to change begin-word to the word in the word-List until to reach the end-word

  • @tuntumwakalasya5270
    @tuntumwakalasya5270 6 หลายเดือนก่อน

    Is this question like bus routes the hard question ? Great video

  • @yohahnribeiro6029
    @yohahnribeiro6029 5 หลายเดือนก่อน +1

    Random observation, but in the slide that shows the final BFS solution, I think the code that checks if the new word is in the word list and not in the visited and not the word itself, needs to be indented to sit under the inner for loop?

    • @Codebagel
      @Codebagel  5 หลายเดือนก่อน +1

      Good catch… 😅 after hours and hours of editing you’d think I’d catch everything but sometimes something slips through. Thanks for catching that!

    • @yohahnribeiro6029
      @yohahnribeiro6029 5 หลายเดือนก่อน

      Hahah I'm sorry, didn't mean to devalue the effort at all. This video was incredible and thank you very much for making it 🎉❤

    • @Codebagel
      @Codebagel  5 หลายเดือนก่อน +2

      @@yohahnribeiro6029 Haha no worries not at all! I actually like it when people point things out because I know to keep an eye on that for future videos! Only way to grow is to learn from mistakes, so thank you 😁

  • @moveonvillain1080
    @moveonvillain1080 6 หลายเดือนก่อน +3

    4:52 me crying in my $13/day full time frontend developer job

  • @osc8468
    @osc8468 3 หลายเดือนก่อน

    Thanks!
    It seems your solution is not working, there is a Time Limit Exceeded but great explanation anyway.

  • @amusicated
    @amusicated 3 หลายเดือนก่อน

    the link to the flowchart doesn't work for me unfortunately

  • @aninditabatra3810
    @aninditabatra3810 6 หลายเดือนก่อน +1

    love this video!

    • @Codebagel
      @Codebagel  6 หลายเดือนก่อน

      Thank you!

  • @DSASolutions
    @DSASolutions 2 หลายเดือนก่อน

    Useful ❤

  • @hossain9410
    @hossain9410 5 หลายเดือนก่อน

    is it neccessary to have any achievements in coding competitions to land a job???

    • @adyan4010
      @adyan4010 5 หลายเดือนก่อน

      Not mandatory but will be a plus point in your resume

  • @1234victorxD
    @1234victorxD 5 หลายเดือนก่อน

    Dude im doing an interview in a week and you might made me land a job... You know what? if you did I will pay back to you and the community. See you in a week!

    • @jeffreydijkstra3391
      @jeffreydijkstra3391 5 หลายเดือนก่อน

      dude, what happend? :D

    • @1234victorxD
      @1234victorxD 5 หลายเดือนก่อน

      @@jeffreydijkstra3391 They postphoned my interview and its going to happen tomorrow! wish me luck!

    • @1234victorxD
      @1234victorxD 5 หลายเดือนก่อน

      @@jeffreydijkstra3391 Sup! I just received the answer that they are not going to hire me... even tho I have solved every code challenge in optmal solution and with no bugs. I Also did a nice System Design Interview... I think I might have been declined because of the Behaviour questions...

  • @s8x.
    @s8x. 5 หลายเดือนก่อน +1

    wait i need this flowchart

    • @Codebagel
      @Codebagel  5 หลายเดือนก่อน

      Check the pinned comment - it’s completely free!

  • @nintendopro0391
    @nintendopro0391 6 หลายเดือนก่อน +38

    I hate how interviews force Leetcode questions. Super annoying. I couldn’t get through the first problem.

    • @dss963
      @dss963 6 หลายเดือนก่อน +22

      The more you are good at solving these problems, the more you are able to come up with solutions for real-world probelms.The probelms test your ability to understand the requirements and write corresponding code for the same. So that's only way to test logical and analytical capabilities of a programmer.

    • @helloworld_69-g2m
      @helloworld_69-g2m 5 หลายเดือนก่อน +6

      @@dss963 btw leetcode is not real world problem solving after solving few question I realized that

    • @dss963
      @dss963 5 หลายเดือนก่อน

      @@helloworld_69-g2m you may come to use your intellectual and logical thinking where you might need to optimise the code for large data volumes. In such scenarios what you learned in algorithmic part come into play. And data structures btw is the core for a software developer or programmer.

    • @the-snailinator
      @the-snailinator 5 หลายเดือนก่อน +6

      ​@@dss963 I remember all the times I used DP to model roles and users with active record... Hmm that can't be right. Maybe that was when I added some endpoints to a rest api.. Nope... Hey maybe it was inside a Temporal workflow I made? Or adding payment handling by integrating with Stripe? Nah.

  • @taradean.
    @taradean. 6 หลายเดือนก่อน

    thanks!

  • @AlienAndrew51
    @AlienAndrew51 5 หลายเดือนก่อน +1

    Worked at several fortune 500s without learning advanced leetcode, can only solve the easy problems which is what is mostly required at most companies.

  • @shivamsiddharthasinghrajaw7671
    @shivamsiddharthasinghrajaw7671 5 หลายเดือนก่อน +5

    these things come naturally when you've practiced enough

  • @oooooooooOoOoOo571
    @oooooooooOoOoOo571 2 หลายเดือนก่อน

    well the problem is im not even getting an interview offer to show off my leetcode skills god damn it

  • @AdithyaRaj-dc9lv
    @AdithyaRaj-dc9lv 5 หลายเดือนก่อน

    Can ai solve these qns?

  • @haniissa1990
    @haniissa1990 5 หลายเดือนก่อน

    from 2:32 , from dog ->lot I had to change two letters ? not one at the same time.

    • @BlackwaterEl1te
      @BlackwaterEl1te 5 หลายเดือนก่อน

      he went from dog -> log you can skip words in the list..

  • @suryapratapsingh5046
    @suryapratapsingh5046 4 หลายเดือนก่อน +1

    Me who is grinding for a free t-shirt from leet code 😂

  • @ItWasEnder
    @ItWasEnder 5 หลายเดือนก่อน +1

    Filthy Frank reference, the goat

  • @powerHungryMOSFET
    @powerHungryMOSFET 5 หลายเดือนก่อน +5

    Leetcode is used for cracking interviews. It has nothing to do with talent. Even a cab driver can do it if he puts some time and effort’s

  • @techandnavid
    @techandnavid หลายเดือนก่อน

    🔥

  • @sureshdurairaj9316
    @sureshdurairaj9316 2 หลายเดือนก่อน

    Background music is annoying when using headphones. It’s distracting.

  • @Salah-YT
    @Salah-YT 5 หลายเดือนก่อน +9

    Easy title, but why such a hard question, bro? You don't seem to care about beginners like me. You choose great content, but why explain such difficult problems? I couldn't even understand what you were talking about. Anyway, thanks.

    • @Codebagel
      @Codebagel  5 หลายเดือนก่อน +20

      Hi Salah, I’m sorry that it seemed too difficult! I intentionally wanted to choose a question that most people would consider “hard” to show you that if you follow these steps, you can solve any question, even if it’s very difficult. May I ask which parts you couldn’t understand? Maybe I can provide clarity and make my future videos better.

  • @sproutboot
    @sproutboot 3 หลายเดือนก่อน +1

    Ha~ some questions sadly i dont get it even i see the solution and watch yt. Anyone has experienced same thing ?

    • @smalltiny
      @smalltiny หลายเดือนก่อน

      Look up dynamic programming

  • @SezayirDagtekin-l3v
    @SezayirDagtekin-l3v 3 หลายเดือนก่อน

    )If some idiots didn't solve these questions for interview.., we wouldn't have to spend time on them to get a job.

  • @brockormond4131
    @brockormond4131 6 หลายเดือนก่อน

    13:10 So something that's been bugging me... is the things and the baby chocobos' butts their egg shell? But most look like plants, so are chocobos... plants? Flying/Grass type pokemon?

  • @paragggoyal1552
    @paragggoyal1552 5 หลายเดือนก่อน

    just solve more problems

  • @Mubashir7933
    @Mubashir7933 5 หลายเดือนก่อน

    you didn't show the solution of dog problem and lot was not possible and you straight jump into your own solution

  • @s2_ultimatetech655
    @s2_ultimatetech655 6 หลายเดือนก่อน +2

    Ae bhaiya ji job lag gyi hai????

    • @Codebagel
      @Codebagel  6 หลายเดือนก่อน +4

      Hanji mere paas job hain (hopefully that makes sense, still learning the language)

  • @mfgd-qo2yo
    @mfgd-qo2yo 5 หลายเดือนก่อน +1

    бибиксонаф .

  • @jayrigger7508
    @jayrigger7508 2 หลายเดือนก่อน +1

    You start off with an insult .. "leetCode is the bane of wannabe engineers". Not being into code puzzles is not a sign of engineering skill.

    • @CW-ln7zt
      @CW-ln7zt 2 หลายเดือนก่อน +1

      Calling react devs “engineers” is a stretch. Engineering is all about solving problems and puzzles

  • @Alfakatt
    @Alfakatt 5 หลายเดือนก่อน

    I’ve made a pretty good living never solving a leetcode in my life or even ever logged into the site

  • @domf21
    @domf21 6 หลายเดือนก่อน +4

    Is def the N word

  • @_bigthor
    @_bigthor 2 หลายเดือนก่อน

    I've never done any leetcode problem and I haven't had any problem to get a job

  • @vectoralphaSec
    @vectoralphaSec 6 หลายเดือนก่อน +1

    Im not doing this shit.

  • @KushLemon
    @KushLemon 6 หลายเดือนก่อน +3

    Useless video.

  • @Everyday_smarter
    @Everyday_smarter 3 หลายเดือนก่อน

    nice solution

  • @go4amitshah
    @go4amitshah 6 หลายเดือนก่อน +1

    This is soooooooo good. Thank you so much for the video 🤌

    • @Codebagel
      @Codebagel  6 หลายเดือนก่อน

      I’m glad it helped!