NEXT PERMUTATION | LEETCODE # 31 | PYTHON OPTIMAL SOLUTION

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

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

  • @jonathanramirez3455
    @jonathanramirez3455 ปีที่แล้ว +41

    Apart from your clear explanations and illustrations, I love your candid commentary. It makes me feel a lot better when encountering mediums that take the whole day to understand and am questioning my sanity.

    • @crackfaang
      @crackfaang  ปีที่แล้ว +11

      I got asked this in an interview once. Luckily had it memorized and sounded confident enough in my delivery that the interviewer didn't question whether I understood why the algorithm would work 🤣

  • @Boosy1125
    @Boosy1125 11 หลายเดือนก่อน +46

    The casual "Fuck" at 6:53 is gold LMAO

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

      Yea it's one of those problems lol

    • @xyxytx
      @xyxytx 8 หลายเดือนก่อน +2

      I like that part as well.

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

    This video is so much easier to follow than the others. I hate this problem too (which is why I’m here), but this seems intuitive and I guess we don’t have much of a choice when interviewing 😂. Great video!

  • @Zaratch
    @Zaratch 3 หลายเดือนก่อน +9

    15 seconds in and I realize I am not alone when it is about hating this problem

  • @Roboticdock
    @Roboticdock 2 ปีที่แล้ว +6

    It became my favorite problem in LeetCode series so far because of you made it crystal clear!

    • @crackfaang
      @crackfaang  2 ปีที่แล้ว +9

      Haha you might be the first person to ever say Next Permutation is their favorite Leetcode problem

  • @aidanjabb
    @aidanjabb 22 วันที่ผ่านมา

    Thank you for the honesty at the beginning, I thought I was the only one who had no intuition for this problem lol

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

    I've watched so many of your videos and every single one I have seen has been a literal god send. The problem sucks ass but, you make it suck way less. Appreciate your hard work.

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

    First time to know that we can add an "else" for the for loop :D, Thanks for the explanation though!

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

      Yea it's definitely something I learned during Leetcode as well I had no idea lol

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

    I am strugggling with this problem and starting to think I am stupid. I try again and again but can not find a proper solution until I see your video. I will continue to exercise again and try to learn the way to problem-solving. I dont want the solution only but the thinking to the solution also. Thanks so much.

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

    I noticed an interesting edge case that may not have been discussed in the video. The algorithm I came up with was very similar to the solution in the video, but instead of my while condition being nums[swap]

  • @SatinderSingh71
    @SatinderSingh71 ปีที่แล้ว +7

    Best Description Ever by Cracking FAANG: This is #1 BS

    • @crackfaang
      @crackfaang  ปีที่แล้ว +3

      Thank god for Leetcode! They ask bullshit questions, I memorise the code from the solutions tab 😂

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

    Your explanation isn't as terrible as you made it out to be lol ngl I nearly skipped this one but chose to give it a shot anyways. Thanks for the vid!

  • @saratabassi6838
    @saratabassi6838 2 ปีที่แล้ว +1

    Thank you so much for making this video!! I hate this problem too but your explanation made me hate it a lil less :)

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

    Excellent solution and explaination ! but having trouble with understanding how you decremented swap but till the last element got swapped with the pivot element ....

  • @rsKayiira
    @rsKayiira 2 ปีที่แล้ว

    Excellent explanation actually and the code is efficient. Only issue I have is with the else statement after a for loop. I simply used "if pivot == None: nums.reverse()". Otherwise this is the best explanation of the problem out there!!

    • @crackfaang
      @crackfaang  2 ปีที่แล้ว +3

      It’s a Python thing. You can include an else statement at the end of a for loop which will run if no return/break is hit by the time the loop ends

    • @rsKayiira
      @rsKayiira 2 ปีที่แล้ว

      @@crackfaang okay got it!

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

    that else statement is so cursed LOL. I had absolutely no clue you could do that! I wonder if doing that in an interview would bother some interviewers? :)

  • @gkapoya
    @gkapoya 2 ปีที่แล้ว +2

    Thanks, this was the best explanation, but seriously how is one supposed to figure this on a whiteboard lol 🤣

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

    thanks for the clear explanation, one question, does splicing use extra memory?

  • @abdurrahmanhabibie6153
    @abdurrahmanhabibie6153 ปีที่แล้ว

    could you please make explanation on 1611. Minimum One Bit Operations to Make Integers Zero too? i still didnt understand that problem

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

    9:31
    [1, 4, |5|, 8, 7].
    "you swap it to the first largest number to the right of the pivot that's greater than 5"
    *chooses 7* ???

  • @ericlin3931
    @ericlin3931 2 ปีที่แล้ว +1

    This is a really good explanation! Early yourself a sub :))

  • @YT.Nikolay
    @YT.Nikolay 2 ปีที่แล้ว +1

    you don't like the problem, but anyway liked it :D Thanks for the video! my brain hurts, but it does for most of the problems, I consider this pain as a study process (hope it's not a tumor :D )

    • @crackfaang
      @crackfaang  2 ปีที่แล้ว

      Haha there’s some questions you learn to understand the topic, and there’s some you learn because you have to. This is definitely one you just memorize, it’s horrible

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

    In love with the comments :-)

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

    reversed(nums) in Python uses O(n) space, not O(1). It creates a new list.

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

      The video is over 2 years old. They must have changed the problem to ask for it in place. This was the old official solution

  • @leetcoderafeeq2641
    @leetcoderafeeq2641 2 ปีที่แล้ว

    People with 199 IQ: Damn it :(

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

    This was a great walk through of the algorithm. For those who are looking for a break down of the intuition of the algorithm (or just want to understand how permutations works), This video does a great job th-cam.com/video/quAS1iydq7U/w-d-xo.html

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

    6:54

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

      😂

  • @AmolGautam
    @AmolGautam ปีที่แล้ว

    thanks

  • @armankhondker
    @armankhondker 8 หลายเดือนก่อน +3

    This was honestly a pretty bad explanation. The classic "I think it makes more sense if we look at the code" is such a cop out for not just preparing a few more clear examples and actually walking through them.
    Your usual videos are much better quality tbh. This one just feels like you kinda gave up and were like we just have to follow this formula which you have no idea how it was derived.

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

      Great I'll await your video on the topic and make sure to leave you a thumbs up and a subscription for explaining it better than I can. It's just one of those questions that's beyond stupid. Not every video is going to be perfect, some questions really are just shit and your best beet is to memorize the solution and make do the best you can. Just the nature of the game

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

      @@crackfaang fair enough, at least you acknowledge it isn't the best video. you're def right this game is very dumb

  • @saratabassi6838
    @saratabassi6838 2 ปีที่แล้ว

    Could you also pls make a video on 1268. Search Suggestions System? I'd really appreciate it. Thanks!

    • @crackfaang
      @crackfaang  2 ปีที่แล้ว +3

      Sure thing! I don’t have any videos on Tries on my channel so should be a good video to make

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

    Thanks