Table of Contents: The Problem Introduction 0:00 - 0:55 The Approaches 0:55 - 1:58 Investigation: How Are Permutations Built? 1:58 - 7:47 Case Analysis: Deducing The Next Permutation 7:47 - 11:10 Time Complexity 11:10 - 11:42 Space Complexity 11:42 - 11:56 Wrap Up 11:56 - 12:21 The code for this problem is in the description. Fully commented for understanding and teaching purposes.
@Official-tk3nc4 жыл бұрын
Some Useless channels are getting 10 million subscribers but useful channels like these are still in their 100ks . THIS PROVES ONLY a FEW PEOPLE ARE SERIOUS
@BackToBackSWE4 жыл бұрын
lol nah it makes sense
@vaibhavtiwari65403 жыл бұрын
Knowledge never sells.
@avinandanbanerjee95684 жыл бұрын
I envy the intern you're going to mentor in a few years at Twitter. This was a brilliant and very lucid explanation!
@BackToBackSWE4 жыл бұрын
thanks heh
@AlexTran3 ай бұрын
This man is the most talented person I've ever watched on KZbin.
@vedantiyangar1515 жыл бұрын
Every one of your videos gives me a light-bulb moment. I always say a loud "Ooooooooooooooooo" when I actually understand how things work. You're on another level, Ben.
@BackToBackSWE5 жыл бұрын
hahaha nice
@ivanluchev79964 жыл бұрын
This is the best explanation one could give for permutations. The build-up makes it really easy to put the pieces of the algorithm together.
@janvisingla37464 жыл бұрын
Thank you for the great content :) . I spent like 3 hrs on this ques watching many videos and wasn't able to understand at all and suddenly land at your video and i was like "WOW HE IS SO GOOD" .Thank you again from INDIA :)
@BackToBackSWE4 жыл бұрын
sure from AMERICA
@shubhamchopra55185 жыл бұрын
You make a hard problem so easy to understand! Keep adding more content. Thanks, Benyam!
@BackToBackSWE5 жыл бұрын
sure ha, I'm taking a bit of a break from this channel and run a private class now. But I have a cool video coming soon
@jy88874 жыл бұрын
The best explanation I could find on the internet. I highly recommend this channel!
@BackToBackSWE4 жыл бұрын
thanks
@symbol7672 жыл бұрын
You're doing Gods work bro, especially with that video breaking down finding the permutations, that was legendary. Thank you man!
@BackToBackSWE2 жыл бұрын
Thanks bud! try out some more amazing stuff in our 5 day free mini course backtobackswe.com/
@Hav0c10004 жыл бұрын
Really nice job! I read a couple articles about this problem, but none of them beat your walk through. This was great. I love how you walk through most algorithms without even having to touch a line of code... i honestly think that helps in absorbing the material...
@BackToBackSWE4 жыл бұрын
nice
@NoName-ef2gv3 жыл бұрын
Crystal clear. You are one of the best teachers on youtube. Thank you.
@abhilashgoyal22344 жыл бұрын
For those who are not getting this logic in one go, please refer to code first, try to think the logic, build a picture in your mind ( very high level) and then see this video. Perfect
@BackToBackSWE4 жыл бұрын
ye
@bahdjibrildjibril5 жыл бұрын
This is for sure my new go to resource. I love the clarity and the fact that you take the time to explain very well in details. I just feel like you explain this just like I need. Thanks so much again for the efforts.
@BackToBackSWE5 жыл бұрын
thanks! check this out late July twitter.com/thebigoguide, it is the next leg of this project
@shubham_sinha14 жыл бұрын
My goodness .....what an amazing explanation !!! U make any problem so so easy ......I saw ur explanation video on kadane's algorithm and subscribed immediately!!!
@BackToBackSWE4 жыл бұрын
great to hear
@Kgp-ty5dk5 жыл бұрын
fantastic explanation! I implemented this two years ago. revised everything in 10 minutes and implemented again!
@BackToBackSWE5 жыл бұрын
nice!
@watchClips6613 жыл бұрын
That's a brilliant way to approach the problem. Thanks!
@clashingwithsahib3 жыл бұрын
Your 30 minutes of back to back recursion backtracking and this video made my concept of next permutation crystal clear thanks.
@mithunk92105 жыл бұрын
Your videos are a saviour to me! I bet most courses can't match the passion and dedication you put into these videos! Hats off!! Thank you so much for giving me hope that I can solve all the questions with the right thought-process and practice. I have been recommending your videos to all my friends who are struggling with interviews. Thanks again!!!
@BackToBackSWE5 жыл бұрын
haha thanks
@alexpena99274 жыл бұрын
i came here for leetcode help, now I am rethinking my entire life because I did not notice the 3
@BackToBackSWE4 жыл бұрын
ye
@AE-ql7vo4 жыл бұрын
Dude! You’re really talented in simplifying tough concepts. Thanks a lot!
@BackToBackSWE4 жыл бұрын
sure!
@rohan8arora5 жыл бұрын
nobody explained it like you did. Kudos!
@BackToBackSWE5 жыл бұрын
thanks
@DiaryOfMuhib5 жыл бұрын
The only video where I got an in-depth explanation. Thanks a lot.
@BackToBackSWE5 жыл бұрын
ye
@prachurjyabasistha46824 жыл бұрын
This is the best explanantion for this problem!!
@BackToBackSWE4 жыл бұрын
thanks
@tumble_dont_fall4 жыл бұрын
man. you're actually blessed with knowing how to explain. this is like...really, really awesome explanation. nice work!
@BackToBackSWE4 жыл бұрын
I'm normal. and thanks and thanks
@akashmittal5638 Жыл бұрын
This is the best possible explanation there can exist on this problem. I've seen lots of your amazing videos before, but this one is by far the best. I don't think I can ever forget this simple logic, thank you Ben!
@BackToBackSWE Жыл бұрын
Thank you, appreciate it 😄 Also check out our Free 5 Day DSA Interview Prep Mini-Course - backtobackswe.com/ 🎉
@ishan78242 жыл бұрын
Finally someone who hasn't crammed the algorithm. Thank you for this gem :)
@BackToBackSWE2 жыл бұрын
Thank you, glad you liked it 😀 Do check out backtobackswe.com/platform/content and please recommend us to your family and friends 😀
@snlagr4 жыл бұрын
i like the yellowish color tint of this video. Kind of soothing to watch.
@BackToBackSWE4 жыл бұрын
lol - it was a mistake
@abhishekthakur66125 жыл бұрын
The way you explain is just awesome. The clarity in explanation and presentation , the way you emphasize on an algorithm is just too elaborative. Thanks. Love from INDIA ❤❤
@BackToBackSWE5 жыл бұрын
thanks :)
@animatedzombie643 жыл бұрын
best ever explanation for this problem on the youtube.
@narihanellaithy77265 жыл бұрын
I loooooove you! I was about to lose my mind! saw this problem in EPI and I was like wtf! Thank you :')
@BackToBackSWE5 жыл бұрын
nice
@hritiksaroj31474 жыл бұрын
Would love to see some design questions on your channel!!!Btw Awesome explanation!!
@BackToBackSWE4 жыл бұрын
will do
@李泽鑫-c1v5 жыл бұрын
This should be one of the best explanation people can see. Your videos should deserve way more views. But keep going, I believe that there will be way more people subscribing your channel.
@BackToBackSWE5 жыл бұрын
thanks
@prakharsingh6202 жыл бұрын
What an explanation man Great work
@resetengineering2 жыл бұрын
This is hands down the best explanation. Watched a couple of videos which even claim to explain intuition, but they don't really. There were micro points in my mind that were cleared at each point of the video. Hooked me on to get through it with patience. Else I switch due to BS
@BackToBackSWE Жыл бұрын
thank you so much!
@ShivamShukla-uz9xs4 жыл бұрын
Thanks a lot for such a beautiful and intuitive explanation from the scratch and origin of the problem. How you drove the case analysis to the conclusion to solve the problem was really the awesome part. Thanks that helped a lot.
@BackToBackSWE4 жыл бұрын
Sure.
@vanshikabajaj43233 жыл бұрын
literally amazing! i have gone through a lot of videos but the way you explained is amazing dude.
@zionhuang59935 жыл бұрын
DUDE! Your explanation is best I have ever seen! Your thought about the process of permutation really help me. You have real talent.
@BackToBackSWE5 жыл бұрын
sure
@szarusz4 жыл бұрын
A fantastic explanation. I knew this problem, I knew the solution, but I never understood it as deeply as I do right now.
@BackToBackSWE4 жыл бұрын
great
@amishagupta26945 жыл бұрын
Literally my first comment on You Tube. Your explanation is one of the best I have seen online
@BackToBackSWE5 жыл бұрын
ay nice, welcome
@mayanksharma-qv4qm5 жыл бұрын
dude you are amazing, you deserve a lot more subscriptions!
@BackToBackSWE5 жыл бұрын
thanks
@alokuttamshukla4 жыл бұрын
Holy moly !!! what an explanation you have put.
@BackToBackSWE4 жыл бұрын
thanks
@mystryb3454 жыл бұрын
Bro your Are GOAT
@BackToBackSWE4 жыл бұрын
thanks
@dochaar4 жыл бұрын
Benyam, thank you so much for your efforts. You have explained things in a way most people can't! There is a huge difference in knowing things and teaching them in a way to make others understand. You have certainly mastered that art. I once watched a video on youtube about linked lists by Dave Feinberg almost 8 years ago and till date it's imprinted in my memory. And, I pretty much solved any linked in question after that. Your explanation is definitely as good as it! I have a seen a few other videos made by you, especially the one on bit shifting (adding two numbers without using add operand). I became your fan after that! Thank you so much sir! Keep doing what you do the best :)
@BackToBackSWE4 жыл бұрын
much thanks, all the best
@harimlee21724 жыл бұрын
My first comment on KZbin -- this is such a great explanation thank you so much!
@BackToBackSWE4 жыл бұрын
great and thanks and sure
@manasbohat68834 жыл бұрын
Best video on this problem on the internet
@manokumar893 жыл бұрын
Amazing explanation. Concentrating on the intuition on how to come up with that algorithm and why this algo works rather than stating that this is the algo, this is the code and this is how the code works (which is what is explained almost everywhere). Thank you so much. Gonna see all the videos in your page _/\_ Best 12 minutes spent on youtube.
@yunlongsong45215 жыл бұрын
Great video. The algorithm is easy to remember, but not understanding it completely could cause negative effect in an interview. Thank you for your intelligible explanation!
@BackToBackSWE5 жыл бұрын
sure
@gautamkumarshukla30553 жыл бұрын
Very good explanation , as it not only explains how to do it, but also tells underlying pattern for why to do it this way
@linarudashevski1665 жыл бұрын
what is the link to the permutation video referenced around 1:52?
@BackToBackSWE5 жыл бұрын
Should be somewhere in the channel videos
@jinliu59285 жыл бұрын
Great explanation on decreasing order is the last state of permutation!
@BackToBackSWE5 жыл бұрын
thanks
@minicraft91583 жыл бұрын
if i have to define this video in one word.. i would say...'brilliant'
@nelsonthekinger4 жыл бұрын
Impressive explanation! A "Real Intellectual Jump"! I was bubble sorting the right side for no use! Thank you very much, this is star quality material!
@BackToBackSWE4 жыл бұрын
sure
@thinja3 жыл бұрын
Amazing. I thought I would never understand this from first principles, but you did it!
@armaanpathan18563 жыл бұрын
Whenever I need to understand the logic of how things work in complex programs Step 1 youtube Step 2 Search Back to Back SWE ... and I live happily forever after 😂 Thank you for this great explanation ❤
@nickk50502 жыл бұрын
wow great explanation, I figured it out along the way w/ ur leading discussion
@anonymousvine41053 жыл бұрын
A slightly more intuitive way to think of it is that you’re given an integer, then your task is to find the very next integer greater than this one by only using the digits given. You want to consider the set of unused digits from right to left. For example 45321. Check the tens place, is 1 > 2? No. Okay, we’ve exhausted our unused digits, add 1 to the unused set, then backtrack to the hundreds place. Are 1 or 2 > 3? No. Add 3 to the decision space and move on to the thousands place. Continue with 5. Are 1, 2 or 3 > 5? No, so add 5 to the unused set and backtrack to the ten-thousands place. Is 5 > 4? Yes, so now we want to construct the smallest integer we can that starts with 5 and must use 1, 2, 3, 4. Stepping back, we see that 45321 would indeed come before 51234 if these were the only digits we could use to construct integers. The algorithm is more natural to think of if we go back to our grade school intuition of how to construct bigger numbers.
@amitranjan69985 жыл бұрын
Hi , i am little bit confused in the example i.e 7:52 minutes , can't understand what you means by putting 6 to the space ,it's going out of space , then 2 , why ?
@BackToBackSWE5 жыл бұрын
6 is already planted (at index 0), 2 is already planted (at index 1), 1 is already planted (at index 2). These tell us what numbers we have left to work with to populate going forward in our recursion. Does this make sense?
@amitranjan69985 жыл бұрын
@@BackToBackSWE Thanks got it , i really likes your video .Thanks alot , if you can make more video on the dynamic programming and backtracking ,kindly do so . Your effort is really helpful to others .
@MithleshKumar-iz1dz5 жыл бұрын
Great and simple. Thanks BTB SWE team!
@BackToBackSWE5 жыл бұрын
Hahaha it is just me now, but I'm working with others shortly.
@vaibhavkumar48215 жыл бұрын
Thanks and kudos for the on-point in-depth explanation for not so simple problem. Do you have any other recommended problems for exercise that revolve around the core idea explained in this problem?
@BackToBackSWE5 жыл бұрын
generating permutations (the problem) is a good followup
@vaibhavkumar48215 жыл бұрын
@@BackToBackSWE Thanks :)
@neelmanivispute11225 жыл бұрын
Thank you so much for helping out beginners like me. :) . Keep it up.
@BackToBackSWE5 жыл бұрын
Sure, you will not be a beginner forever. Remember that.
@4sky5 жыл бұрын
So algo is.. 1) find the decreasing section at the end of the array 2) the item before the decreasing section swap with the next biggest number in the decreasing section. 3) reverse the decreasing section.
@BackToBackSWE5 жыл бұрын
yes, but make sure u know why, the pattern is simple, the why is deeper
@Adam-tz6gk2 ай бұрын
Beautiful explanation right here folks
@harshg72623 жыл бұрын
Incredible explanation, I have no clue how any company excepts someone to figure this out in 45 minutes tho
@kshitij339414 күн бұрын
Bro really loved your way of explanation. Kudos 👏
@abdaa55794 жыл бұрын
Thanks for explanation. You are a good teacher.
@BackToBackSWE4 жыл бұрын
thx
@kartikdutta54104 жыл бұрын
Amazing works. Hats off to your detailed explanation
@BackToBackSWE4 жыл бұрын
thx
@मयंकपठानियाँ3 жыл бұрын
thanks I didn't even understood "lexicographical permutation" from problem but you explained it well.
@ec59883 жыл бұрын
Takes a legend for me to leave a comment and you sir, are a legend
@leonardocavalcanti12252 ай бұрын
Thanks a lot! Greetings from Brazil!
@rajparekh083 жыл бұрын
very very well explained.
@konfukuzawa5 жыл бұрын
Such a clear explanation, thanks buddy!
@BackToBackSWE5 жыл бұрын
sure
@deepakprajapati26354 жыл бұрын
great explanation, I hate those videos in which they first write code and show how their code works. I like the kind of videos made by you
@adityadhanrajtiwari4 жыл бұрын
You are amazing bro ,you make programming interesting. ☺️
@BackToBackSWE4 жыл бұрын
ye
@atulmalakar5 жыл бұрын
I am in love with your explanation! ❤
@BackToBackSWE5 жыл бұрын
thanks
@SmokyBigSmoke4 жыл бұрын
Can't thank you enough.This explanation was so good.
@BackToBackSWE4 жыл бұрын
sure!!
@syedsafdarali42874 жыл бұрын
Smooth explanation LOVED IT!
@BackToBackSWE4 жыл бұрын
thanks
@AdityaGuptaYouTube5 жыл бұрын
This video is just mind-blowing. One of the most elegant solutions!! I watched some of your videos and tried my best to solve them by myself, but the approach of this question is just very very good. Keep up the good work buddy, and keep posting videos like this. :)
@BackToBackSWE5 жыл бұрын
yessir
@siyiyu19163 жыл бұрын
Really like your video! Especially helpful for leetcode beginner like me!
@greentealatte28454 жыл бұрын
thank you!!!
@BackToBackSWE4 жыл бұрын
sure!
@gyanasahu10064 жыл бұрын
Very nicely explained indeed!!
@BackToBackSWE4 жыл бұрын
thx
@no5xx5 жыл бұрын
Awesome explanation dude. Would love to support your cause !!! xD
@BackToBackSWE5 жыл бұрын
yo
@harshitpandey6385 жыл бұрын
Really amazing video , im blown away .
@BackToBackSWE5 жыл бұрын
ye
@ChrisKSPКүн бұрын
Dang that was a great explanation and you didn't even need to tell us any code.
@umapathybabu83974 жыл бұрын
excellent video, made to understand the problem clearly. looking more from you. can you do some oo design questions?
@BackToBackSWE4 жыл бұрын
sure
@fanchelsea8444 жыл бұрын
thank you for your videos, they are great and easy to understand. Saludos desde México.
@BackToBackSWE4 жыл бұрын
wassup!
@MuhammadIrshadAli4 жыл бұрын
Thank you for making such a great video.
@BackToBackSWE4 жыл бұрын
sure
@tenki_desu4 жыл бұрын
牛逼啊 English Translation: This is freaking AWESOME And this is the BEST explanation I have ever heard for the next permutation problem.
@BackToBackSWE4 жыл бұрын
thanks lol
@geesehoward88384 жыл бұрын
great video and great explanation!
@BackToBackSWE4 жыл бұрын
thanks!
@JacobAbraham-twozerosix5 жыл бұрын
Thank you! For this... I struggled with this quite a bit... Just could not see the pattern.
@BackToBackSWE5 жыл бұрын
sure
@rohitsanjay14 жыл бұрын
You're a legend
@BackToBackSWE4 жыл бұрын
no im normal
@liangtang21275 жыл бұрын
amazing explanation! it really helps me understand what leetcode 32 wants me to do :)
@BackToBackSWE5 жыл бұрын
nice
@niwanshumaheshwari45344 жыл бұрын
i guess it's 31
@prodigysonhiddenforareason12393 жыл бұрын
Clear as thin air.
@dontknow73334 жыл бұрын
thanks a lot
@BackToBackSWE4 жыл бұрын
sure
@valkon_2 жыл бұрын
Thanks for the amazing explanation. The interviewers really have the audacity to ask if we seen this question before. Of course we have.
@BackToBackSWE2 жыл бұрын
Thank you, glad you liked it 😀 Do check out backtobackswe.com/platform/content and please recommend us to your family and friends 😀