Next Permutation - Intuition in Detail 🔥 | Brute to Optimal

Sdílet
Vložit
  • čas přidán 22. 03. 2023
  • Problem Link: bit.ly/3WOGkjH
    Notes/C++/Java/Python codes: takeuforward.org/data-structu...
    We have solved the problem, and we have gone from brute force and ended with the most optimal solution. Every approach's code has been written in the video itself. Also, we have covered the algorithm with intuition.
    Full Course: bit.ly/tufA2ZYt
    You can follow me across social media, all my handles are below:
    Linkedin/Instagram/Telegram: linktr.ee/takeUforward

Komentáře • 503

  • @takeUforward
    @takeUforward  Před 10 měsíci +35

    Please watch our new video on the same topic: czcams.com/video/JDOXKqF60RQ/video.html

  • @takeUforward
    @takeUforward  Před rokem +173

    Let's march ahead, and create an unmatchable DSA course! ❤
    Use the problem links in the description.

    • @leoved1073
      @leoved1073 Před rokem +3

      Thanks bhaiya, great explaination.

    • @leoved1073
      @leoved1073 Před rokem

      I was waiting for this video I know you are busy but please try to upload alternate days....

    • @leoved1073
      @leoved1073 Před rokem +1

      ** Timestamps **
      0:42 Explaination of what problem says
      3:26 Brutforce approach
      6:45 Better approach
      7:22 Optimal approach
      24:58 Code

    • @takeUforward
      @takeUforward  Před rokem +13

      @@leoved1073 I was not doing well, the body took a toll.

    • @vishal_s583
      @vishal_s583 Před rokem +2

      Great explanation ❤️

  • @kj5215
    @kj5215 Před 9 měsíci +83

    Brute -> 3:25
    Optimal -> 7:35 obj2: 16:14 logic summary: 18:57 algo 19:31

  • @itzmartin20
    @itzmartin20 Před 10 měsíci +63

    Your intuition approach is so good that I'm afraid can not find anywhere on the internet, some programming education nowadays is kind of distorted by just do it for trend and profit. High quality and dedicated contents are so underrated in my opinion. Again thanks a billion for your great work and dedication! Understood!

  • @riyadhossain1706
    @riyadhossain1706 Před rokem +41

    Truly, humans like you are so much talented and generous to share their knowledge.

    • @parthsalat
      @parthsalat Před měsícem +2

      And AGI won't be this generous 🔥

  • @habeeblaimusa4466
    @habeeblaimusa4466 Před rokem +5

    I have been on your page for the past couple of days. Thanks for all you do we miss you

  • @priyankavasam8769
    @priyankavasam8769 Před rokem +29

    Understood very well. This is the ultimate sheet everyone needs!! Thank you for making such kinda premium content for absolutely free🤩🤩🤩

  • @abhaypandey5933
    @abhaypandey5933 Před rokem +28

    I appreciate your hard work, thanks for making these valuable videos for free.

  • @DevashishJose
    @DevashishJose Před rokem +13

    Understood. Thank you so much for your dedication strive it is very inspiring, I am solving this at 12:02 on a sunday night because I have seen how hard you work to produce these videos, Thanks a lot.

  • @jatinsharma1595
    @jatinsharma1595 Před 7 měsíci +3

    Understood. A very good lecture tbh, the way you walked us through the approach, just loved and enjoyed it. Thanks Striver

  • @maneeshapanu
    @maneeshapanu Před rokem +11

    The best explanation I could have ever asked for. Thank you, Sir.

  • @chaitanyabalanagu626
    @chaitanyabalanagu626 Před rokem +31

    Just in case ur confused,
    //find the first adacent pair from right side where left is smaller than right
    //if you dont find such a pair, reverse the whole array
    //swap the left element in the pair with the smallest element greater than that to its right
    //then reverse the sub array from the point of swap(after the left element in the pair) till the end

    • @shekharsharma3331
      @shekharsharma3331 Před 8 měsíci

      Very good understanding, but in last point you should edit reverse to sort. Because you should sort the sub array from the point of swap(after the left element in the pair) till the end and not reverse from that point. Cause you need the smallest value from those numbers. Not something random by revrseing them.

    • @kk420100
      @kk420100 Před měsícem +2

      @@shekharsharma3331 no need of sorting because after swapping also this part of the array is still sorted. No point of sorting it again

  • @cinime
    @cinime Před rokem +8

    Understood! Wow!! Super amazing explanation as always, thank you very very much for your effort!!!

  • @MrOO-ix5qr
    @MrOO-ix5qr Před 11 měsíci +3

    a channel which can be subscribed without any hesitation or doubt. loving the depth of explanation ❤

  • @muktarsayeed9198
    @muktarsayeed9198 Před rokem +75

    Your explanation was excellent 👍👍👍🙏🙏🙏 but what I find more impressive is you can do this at 3am in the morning 👍👍👍👍

    • @user-cp3rc3yp2s
      @user-cp3rc3yp2s Před 6 měsíci +2

      He doesn't live in india it might be 10 pm for him

  • @atharvagarwal2067
    @atharvagarwal2067 Před 7 měsíci

    Hats down the best video on this topic on the entire internet, was never able to understand this problem but after watching this video everything became so easy.

  • @komalkrishna7836
    @komalkrishna7836 Před rokem +3

    Understood!! Nicely explained Striver!! Thank you so much 😊

  • @Alex-ve9dw
    @Alex-ve9dw Před rokem +6

    waited for this question's intuition video thank you striver for doing this.

  • @krugerbrent4270
    @krugerbrent4270 Před 9 měsíci +3

    Wow, hats off! This is one of the best explanations, that got through my head. Thanks man.

  • @sumithst2386
    @sumithst2386 Před 11 měsíci +3

    What a great explanation! Crystal clear!❤

  • @Dhruv-od3tc
    @Dhruv-od3tc Před 11 měsíci

    Man Your teaching is fantastic even after buying a course for dsa i wasn't able to understand concept this better that you are providing free. Such A Gem Teacher....!

  • @rohitsoni3710
    @rohitsoni3710 Před 5 měsíci +2

    Best explaination of this question in coding community.No one can explain intitution as striver can explain . striver you are legend.

  • @tahaansari5621
    @tahaansari5621 Před rokem +5

    Have been waiting for ur video for the past 3 days

  • @dhruvsolanki4473
    @dhruvsolanki4473 Před rokem +2

    Very well explained the intuition and how the algorithm works, thank you for your great efforts.

  • @113_manshi4
    @113_manshi4 Před rokem +2

    The question was quite complex, but you made it easy, Thank you!

  • @joeljacob4685
    @joeljacob4685 Před 11 měsíci +1

    Hey!! Thank you so much for your awesome explanations . I really understood the intuiton and the problem was awesome too .. Waiting for your further lectures !!

  • @ArvindSingh-wj7vy
    @ArvindSingh-wj7vy Před 4 měsíci

    At first, it was difficult to understand but after watching it again, it is crystal clear

  • @utsavseth6573
    @utsavseth6573 Před rokem

    Damn, dude, that explanation was just simply on some next level.

  • @gurdittsingh6638
    @gurdittsingh6638 Před rokem +3

    Absolutely amazing explanation of the intuition

  • @joydeepsarkar4774
    @joydeepsarkar4774 Před 10 měsíci +2

    This guy is a legend

  • @RahulBisht_001
    @RahulBisht_001 Před 2 měsíci

    Truly admirable! Your dedication level is worth emulating.

  • @nishantagarwal2289
    @nishantagarwal2289 Před 10 měsíci

    Understoooood 😃.
    Learning DSA from u is so easy and fun
    Hats off to you striver

  • @rehanhussan
    @rehanhussan Před 8 měsíci +1

    Feel a gaya concept smajh kar... best explanation thank you bhaiya

  • @prankishoriitkgp3772
    @prankishoriitkgp3772 Před rokem +3

    very well explained I just loved it
    Highly influenced by the intuition and the way he taught in the lecture😘

  • @RamKumar-dm6es
    @RamKumar-dm6es Před rokem

    Great content with complete explanation, You explain the algorithm from basics

  • @satyam_sundaram
    @satyam_sundaram Před rokem

    WOW! What an explanation! Genius.

  • @adarshrishu7972
    @adarshrishu7972 Před 2 měsíci

    What a wonderful explanation, thank you so much for explaining everything from one corner to another. ❤

  • @MANISHKUMAR-th4zq
    @MANISHKUMAR-th4zq Před rokem

    Superb explaination !! Speciality of striver bhaiya is that he focus more on the intution than algorithm. Thanks bhaiya

  • @Raj10185
    @Raj10185 Před rokem +1

    LIiterally the observation you tried to explain is superb and code it my own once observation is clear cut anyone can code it by its own if he know programming language.

  • @stith_pragya
    @stith_pragya Před 2 měsíci +2

    Understood...Thank You So Much for this wonderful video......🙏🙏🙏

  • @prabhakaran5542
    @prabhakaran5542 Před 6 měsíci +1

    Understood Bro! Heartful Thanks for you!

  • @drishtirai864
    @drishtirai864 Před 8 měsíci

    Understood 👍Thank you so much Striver !☺

  • @AbdullahKhan-et6qo
    @AbdullahKhan-et6qo Před rokem +3

    Great explanation of the intuition, Understood 🔥

  • @parthkandwal8343
    @parthkandwal8343 Před rokem

    Understood bhaiya. Hats off to your dedication.

  • @vijaiganeshh1346
    @vijaiganeshh1346 Před 3 měsíci +1

    Really thankful and appreciate ur effort striver thanks a million! 👏

  • @saliqgowhar395
    @saliqgowhar395 Před rokem +1

    absolutely brilliant !

  • @brindhadhinakaran9672

    Very nicely done Striver !!!

  • @Nishantkumar-oh9th
    @Nishantkumar-oh9th Před rokem

    Understoood....This video was much awaited..

  • @sourabhtiwari5137
    @sourabhtiwari5137 Před 4 měsíci

    i was not getiing the problem but now just one thing, u r just awesome

  • @Manishgupta200
    @Manishgupta200 Před rokem

    That's really fantastic. Amazing 🔥🔥Thankyou Striver. Leetcode problem is done by myself.

  • @manvendrasinghrathore8100
    @manvendrasinghrathore8100 Před 6 měsíci

    What a explanation skill you have bro.
    Thanks for quality content .

  • @DR-mq1le
    @DR-mq1le Před 11 měsíci +1

    understood, extremely good explanation!

  • @rajdeepsingh3130
    @rajdeepsingh3130 Před rokem

    Concept is superb explain...I pause the video in middle of it press the like button and then continue..👍

  • @shyren_more
    @shyren_more Před rokem

    Appreciate your hard work!

  • @sachinboreoffl
    @sachinboreoffl Před 5 měsíci

    This is one of the best Logic I came across

  • @purvi9958
    @purvi9958 Před rokem

    nicely explained...thankyou for such an elaborate explanation!

  • @film_fam-zn9mg
    @film_fam-zn9mg Před 29 dny

    What an explaination, loved the way Striver explains

  • @shariyarshajid
    @shariyarshajid Před 11 měsíci

    Thanks a lot, brother. Love and Respect from Bangladesh

  • @chiragarya4201
    @chiragarya4201 Před rokem

    One of the best explained solution. Thanks for the content

  • @prabhagaikwad4849
    @prabhagaikwad4849 Před rokem +4

    I am beginner at DSA and I have gone through the same problem of yours from Array series 2-3 times but intuition was not being clear. But this video has cleared in first few minutes. Thank you so much.
    This A2Z DSA course is world's best course. You have made one the complex topic in IT industry very easy for the world.😍

  • @shreyasdeshpande6653
    @shreyasdeshpande6653 Před 4 měsíci

    understood , this is the best channel ever.

  • @AdityaKumar-be7hx
    @AdityaKumar-be7hx Před rokem

    Had to go over it twice but understood it now!

  • @abhaysinghrathore3192
    @abhaysinghrathore3192 Před 11 měsíci

    Kya hi samjhaya hai bhai. Killed it.

  • @prakritisagar5007
    @prakritisagar5007 Před 5 měsíci

    Thank you for making it super easy to understand!

  • @Raj10185
    @Raj10185 Před rokem

    Understood everything literally amazing explanation bhai :)

  • @DeepakSharma-de6uk
    @DeepakSharma-de6uk Před měsícem +1

    Excellent intuition building teaching... Salute to the hard work.🧑‍💻

  • @naveensaicremsiyadlapalli3769

    amazing explanation , you nailed it.

  • @vm1662
    @vm1662 Před 9 měsíci +2

    Hey Striver, the explanation is amazing. Thank you so so so much!!
    I wonder how you come up with these ways to explain 😅

  • @AayushDubey_007
    @AayushDubey_007 Před rokem

    Your videos are just amazing and helpful

  • @mohammadaquib-computerscie1673

    Thanks a lot for an awesome course
    God bless you

  • @seturaj64
    @seturaj64 Před 3 měsíci

    Best Explanation Ever.. Thank You So Much for all the Efforts. 🍀❤🔥🔥

  • @35-ekta94
    @35-ekta94 Před 8 měsíci

    Thanks for sharing the intuition. It's really helpful.

  • @omsatpathy5455
    @omsatpathy5455 Před rokem

    the god of explaining complex algos..🙏🙏🙏

  • @atishayharsola496
    @atishayharsola496 Před rokem

    Great Course Thanks Striver Bhaiya

  • @sukhpreetsingh5200
    @sukhpreetsingh5200 Před rokem +2

    Amazing Explanation ❤

  • @techwithsaket827
    @techwithsaket827 Před 11 měsíci +1

    just awesome...mja aa gya 🥳🥳

  • @suyashjain3223
    @suyashjain3223 Před 2 měsíci

    Amazing Explanation!!🔥🔥🔥

  • @kaushalsaraswat2674
    @kaushalsaraswat2674 Před 9 měsíci +1

    Understood very well !!

  • @torishi82
    @torishi82 Před 13 dny

    Amazing work. Thanks.

  • @bhanuprakashn6881
    @bhanuprakashn6881 Před 6 měsíci

    by the way your explanation is truly amazing..!!!

  • @tawkeer4
    @tawkeer4 Před 5 měsíci +1

    This was explained very beautifully. Thanks striver

  • @prathamvardaan4187
    @prathamvardaan4187 Před 12 dny

    amazing explanation . the way you explained it is phenomenal.

  • @stelarfox
    @stelarfox Před rokem

    Very well explained. Thank you.

  • @ayushgarg05
    @ayushgarg05 Před 6 měsíci

    Very very easy to understand.
    Great explanation.
    Thanks a lot.

  • @ankitamishra7510
    @ankitamishra7510 Před 3 měsíci +1

    He is made for this ...
    Striver!! Truly you are made to teach DSAlgos!!!!
    Hats off ❤

    • @FaizKhan-jk9po
      @FaizKhan-jk9po Před 3 měsíci

      Are you also studying DSA from this section of the video? If you are, would you be interested in learning together? Please let me know if you're open to learning together.

  • @ritikasinha6929
    @ritikasinha6929 Před rokem

    You are just amazing Striver😌

  • @ToufiqurRahman_
    @ToufiqurRahman_ Před 5 měsíci

    Great video, thanks for it

  • @srinivasmadupada4519
    @srinivasmadupada4519 Před rokem

    I was sure that it was the best channel for DSA 100%

  • @technojam5944
    @technojam5944 Před rokem

    BEST EXPLANATION mjja aa gya 🔥

  • @k.satish3663
    @k.satish3663 Před rokem

    awesome teaching.Thank you very much.

  • @pragatisrivastava8051
    @pragatisrivastava8051 Před rokem +46

    I have always tried to avoid this question because I was unable to digest its solution, but I will recommend all the new users to please watch the solution till end, you will get to know why Striver is the God of coding world.
    Wonderful channel , wonderful content...
    To all my fellow learners : Bus yahan se padhlo naukari pakki hai tumhari!! Naukri hai toh promotion pakka!!!
    Thank you v. much Striver

    • @savage4493
      @savage4493 Před rokem

      avoid this question so do you mean that you try and solve the qsns before watching tutorials? is that the right approach?

    • @pragatisrivastava8051
      @pragatisrivastava8051 Před rokem

      @@savage4493 No, because I was not able to grasp the knowledge, I just used that Stl library to solve this, but now I'm confident enough to write its logic.

    • @harsha4048
      @harsha4048 Před rokem

      Can you explain the logic of the code
      21:32

    • @yumevibes1303
      @yumevibes1303 Před rokem +2

      ​@@harsha4048 first you are looping from backward and checking condition a[ i ] < a[ i+1 ] (so here is dry run a[ i ] < a[i+1] == a[ 4 ] < a[5 ] hear 4 and 5 are index which means a[ 4 ] = 3 and a[5 ] = 0 that means 3 < 0 ( hear its not meet the if condition so it wont go inside the if block ) it will satisfy the if condition only at index 1 { a[1] = 1 and a[i +1 ] = 5} , i hope you get it..

    • @Fe-ironman
      @Fe-ironman Před 6 měsíci

      wow seeing all the comments i am very glad i got stuck in this problem and gave 2 days of time to think solution of this problem on my own on free time while also solving other problems, and got the exact approach on my own lol idk how @@pragatisrivastava8051

  • @souvikmukherjee8245
    @souvikmukherjee8245 Před rokem

    wow. amazing explanation dada. understood

  • @mehraritvik
    @mehraritvik Před 6 měsíci

    love your tutorials man hats off

  • @konankikeerthi
    @konankikeerthi Před měsícem

    understood bro.. thanks for your efforts

  • @adebisisheriff159
    @adebisisheriff159 Před 8 měsíci

    @striver, you are a God in DSA. I Salute you bro!!! Thanks for all you do for us

  • @rohith8269
    @rohith8269 Před 3 měsíci

    Great intuition!

  • @jayanthvanamamala1425

    striver bhaiya .. uh are great thanks for giving us this lecture

  • @vinaymocharla1223
    @vinaymocharla1223 Před 8 dny

    Thank you striver for explaining this hard problem

  • @AnkitGupta-cf6vk
    @AnkitGupta-cf6vk Před 6 měsíci

    Amazing video, subscribed. :)

  • @NitinKumar-wm2dg
    @NitinKumar-wm2dg Před rokem

    Thank you so much bhaiya, ekdum samajh aagaya