NEXT PERMUTATION | LEETCODE # 31 | PYTHON OPTIMAL SOLUTION

  Рет қаралды 9,214

Cracking FAANG

Cracking FAANG

Күн бұрын

In this video, we're going to be solving my absolutely number 1 hated problem on the entirety of Leetcode: Next Permuration (LC # 31).
This problem is an absolute abomination. There's absolutely no chance you ever solve this without either a 200 IQ or having seen it before. I understand how it works, I can't prove to you why it does, but don't question it, just memorize the solution and be on your way. This is the worst problem...

Пікірлер: 39
@jonathanramirez3455
@jonathanramirez3455 Жыл бұрын
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 Жыл бұрын
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 8 ай бұрын
The casual "Fuck" at 6:53 is gold LMAO
@crackfaang
@crackfaang 8 ай бұрын
Yea it's one of those problems lol
@xyxytx
@xyxytx 5 ай бұрын
I like that part as well.
@Roboticdock
@Roboticdock Жыл бұрын
It became my favorite problem in LeetCode series so far because of you made it crystal clear!
@crackfaang
@crackfaang Жыл бұрын
Haha you might be the first person to ever say Next Permutation is their favorite Leetcode problem
@fallencheeto4762
@fallencheeto4762 6 ай бұрын
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!
@zuccca
@zuccca 7 ай бұрын
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 7 ай бұрын
First time to know that we can add an "else" for the for loop :D, Thanks for the explanation though!
@crackfaang
@crackfaang 7 ай бұрын
Yea it's definitely something I learned during Leetcode as well I had no idea lol
@phanthe3471
@phanthe3471 5 ай бұрын
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.
@martingg1
@martingg1 5 ай бұрын
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!
@davidshipman5964
@davidshipman5964 Ай бұрын
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? :)
@saratabassi6838
@saratabassi6838 2 жыл бұрын
Thank you so much for making this video!! I hate this problem too but your explanation made me hate it a lil less :)
@Zaratch
@Zaratch 14 күн бұрын
15 seconds in and I realize I am not alone when it is about hating this problem
@SatinderSingh71
@SatinderSingh71 10 ай бұрын
Best Description Ever by Cracking FAANG: This is #1 BS
@crackfaang
@crackfaang 10 ай бұрын
Thank god for Leetcode! They ask bullshit questions, I memorise the code from the solutions tab 😂
@demic3358
@demic3358 6 ай бұрын
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 Жыл бұрын
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 Жыл бұрын
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 Жыл бұрын
@@crackfaang okay got it!
@jonwein4710
@jonwein4710 5 ай бұрын
thanks for the clear explanation, one question, does splicing use extra memory?
@ericlin3931
@ericlin3931 Жыл бұрын
This is a really good explanation! Early yourself a sub :))
@abdurrahmanhabibie6153
@abdurrahmanhabibie6153 9 ай бұрын
could you please make explanation on 1611. Minimum One Bit Operations to Make Integers Zero too? i still didnt understand that problem
@YT.Nikolay
@YT.Nikolay 2 жыл бұрын
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
@gkapoya
@gkapoya Жыл бұрын
Thanks, this was the best explanation, but seriously how is one supposed to figure this on a whiteboard lol 🤣
@tamaragaidar8986
@tamaragaidar8986 7 ай бұрын
In love with the comments :-)
@subee128
@subee128 8 ай бұрын
Thanks
@leetcoderafeeq2641
@leetcoderafeeq2641 Жыл бұрын
People with 199 IQ: Damn it :(
@balltomessi8515
@balltomessi8515 2 ай бұрын
6:54
@crackfaang
@crackfaang 2 ай бұрын
😂
@armankhondker
@armankhondker 5 ай бұрын
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 5 ай бұрын
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 5 ай бұрын
@@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 жыл бұрын
Sure thing! I don’t have any videos on Tries on my channel so should be a good video to make
@AmolGautam
@AmolGautam 9 ай бұрын
thanks
Next Permutation - Intuition in Detail 🔥 | Brute to Optimal
28:15
take U forward
Рет қаралды 393 М.
Or is Harriet Quinn good? #cosplay#joker #Harriet Quinn
00:20
佐助与鸣人
Рет қаралды 53 МЛН
Electric Flying Bird with Hanging Wire Automatic for Ceiling Parrot
00:15
LOWEST COMMON ANCESTOR OF A BINARY TREE I | PYTHON | LEETCODE 236
12:48
Next Permutation | Leet code 31 | Theory explained + Python code
19:19
Sai Anish Malla
Рет қаралды 14 М.
MERGE K SORTED LISTS | LEETCODE 23 | PYTHON OPTIMAL SOLUTIO
19:33
Cracking FAANG
Рет қаралды 2,6 М.
Dynamic Programming isn't too hard. You just don't know what it is.
22:31
DecodingIntuition
Рет қаралды 141 М.
Next Permutation | Leetcode #31
19:12
Techdose
Рет қаралды 103 М.
The Midpoint Circle Algorithm Explained Step by Step
13:33
NoBS Code
Рет қаралды 17 М.
LOWEST COMMON ANCESTOR OF A BINARY TREE III [PYTHON]
16:38
Cracking FAANG
Рет қаралды 10 М.
Fast Inverse Square Root - A Quake III Algorithm
20:08
Nemean
Рет қаралды 5 МЛН