Next Permutation | Google | Microsoft | Amazon | Leetcode 31

Sdílet
Vložit
  • čas přidán 18. 07. 2022
  • In this video, we will see another popular Array Question "Next Permutation".
    Problem Name : Next Permutation
    Leetcode Link : leetcode.com/problems/next-pe...
    GfG Link : practice.geeksforgeeks.org/pr...
    My solutions on Github : github.com/MAZHARMIK/Intervie...
    Company Tags 😱🤯 : Amazon, FactSet, Hike, Amazon, MakeMyTrip, Qualcomm, Infosys, Microsoft, Google, Salesforce, Flipkart
    My GitHub Repo for interview preparation : github.com/MAZHARMIK/Intervie...
    Subscribe to my channel : czcams.com/channels/aw5.html...

Komentáře • 46

  • @SubhranilDas-bo6ic
    @SubhranilDas-bo6ic Před 3 měsíci +5

    One of the best channels for understanding dsa concepts!❤

  • @ratishjain2718
    @ratishjain2718 Před 5 měsíci +7

    isse behtar explaination ho hi nhi sakta iss cheez ka

  • @rockykumarverma980
    @rockykumarverma980 Před 7 měsíci +8

    100% effort from your side .... such a good teacher .....Thank you so much sir 🙏🙏🙏

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

    Whenever i search for a question and this channel comes up . feels good.

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

    Very welll explained never seen before

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

    I gone through various videos
    Finally I found you & got better understanding with better story

  • @divsworld5925
    @divsworld5925 Před 7 měsíci +4

    Gola suspence during the solution was far greater than any netflix web series cliffhanger😂😂

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

    You explained really well. Thank you!!

  • @B-Billy
    @B-Billy Před měsícem +1

    Brilliant, just brilliant. The way you setup the story, it's sank deep in my soul. Now I will not forget it.
    It's my first video on your Channel, Thanks, Subscribed!

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

    I have done same approach...first write stiry then code

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

    Great explanaation my friend

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

    best explanation so far

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

    Great as always 🎉

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

    Best explanation with intuition 🤩

  • @somakbhuti9501
    @somakbhuti9501 Před 25 dny

    Thanks

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

    easily explained!!

  • @pranavpranjal2717
    @pranavpranjal2717 Před 7 dny

    hi, great explanation, but I just have one question, while finding the swap index how can we be guaranteed that the first element we find is the just greater one , cant we have a condition where the element is greater but not just greater???? pls answer.

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

    Thanks for your efforts, loved your explanation ❤❤

  • @Bhavisshyya
    @Bhavisshyya Před dnem

    hey sir , I have Infosys Specialist interview. Can you suggest me topics I should brush up before interview

  • @lovegarg5061
    @lovegarg5061 Před 17 dny

    Sir its give TLE (time limit exceed)
    With your solution in java

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

    I got this question in one of my interview, but still find difficult to identify the solution. I feel its hard to crack this approach in real interview scenario.
    Thanks for explanation

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

    Bhaiya sab kuch clear ho gya. Hats off. aapki linked in id milegi kya?

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

    Easy Explaination>>>> :):):)

  • @user-hk6ep7ew2i
    @user-hk6ep7ew2i Před 5 měsíci

    video was awesome but i have a doubt when we are finding just a larger element then it is possible that we can get larger element but not just larger than an element

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

    Bhaiya please leetcode 567 bhi krwa dijiye

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

    how would we find last permutation (ie previous one) ?
    if [1,3,2,1,3] then last premutation would be [ 1, 3, 1, 3, 2]

  • @user-pm3nd7ti9q
    @user-pm3nd7ti9q Před 4 měsíci

    Day 2

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

    I literally give 1:30 hours for code after your intitution but not it run 180 cases but failed at 181 cases when i got frustated then i watch your code. ab aaj ke liye kafi hai bahut hua aaj ka .totally exhausted.

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

      It’s totally fine to take breaks and relax your mind. Take rest and then comr back tomorrow with more motivation and let’s do it 💪

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

    algorithm smjh m aagya kese krna h pr ye intuition kese aaya wo pta nai lg rha .. ki hm right side s q smaller element dekhege .. iss logic p kese phoche

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

      ummm. I got it wrong initally. Phale I thought I have to swap with min or max element... then I realized ki at the time of swapping (which is the next permutation) - I must swap myself with the next element larger than me.
      Going from left won't work as the left most element is highest element and there maybe smaller permutations down the line. So first have to explore smaller permutations and only then explore the longer permutations.
      hope this helps. this question was tough (for me :) )

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

    sir to be honest I cannot understand that gola wala part can u explain to me i have watched it multiple times

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

      Gola wo element hai jo iss condition ko satisfy kar raha hai... Arr[n-1] < Arr[n]

  • @sidharthdhiman4522
    @sidharthdhiman4522 Před rokem +1

    bhaiya mera aur apka approach thoda similar , what i did i find that index but now what i did is that i try to find smaller element and swap with goal_index-1 and then just sort the remaining array from gola_ind to last

  • @Ark.01
    @Ark.01 Před měsícem +1

    //java
    class Solution {
    public void nextPermutation(int[] nums) {
    int i=nums.length-1;
    while(i>0 && nums[i]0){
    int j=nums.length-1;
    while(j>0 && nums[j]

  • @HimanshuPatel-wn6en
    @HimanshuPatel-wn6en Před měsícem +1

    Ek mahine phele hi kiya tha yehi video dekh kar aur aaj ekdum sab bhul gaya 😮‍💨🥲

  • @zaviyakhurshid9097
    @zaviyakhurshid9097 Před rokem +1

    How u find the condition arr[i-1] < arr[i]

    • @codestorywithMIK
      @codestorywithMIK  Před rokem +5

      Hi Zaviya,
      Actually it’s totally based on
      1) observation
      2) Seeing how words are ordered in dictionary lexicographically
      I usually do multiple of dry run and take multiple examples. It helps to figure out patterns (if any) that can help to solve qns

  • @rode_atharva
    @rode_atharva Před měsícem +1

    //{ Driver Code Starts
    // Initial Template for C++
    #include
    using namespace std;
    // } Driver Code Ends
    //User function template for C++
    class Solution {
    public:
    void multiply(vector&arr, int multiplier){
    int carry = 0;
    for(int i=0; i< arr.size(); i++){
    int res = multiplier*arr[i];
    res = res+carry;
    arr[i] = res % 10;
    carry = res/10;
    }
    while(carry > 0){
    arr.push_back(carry%10);
    carry = carry / 10;
    }
    }
    vector factorial(int N){
    vectorarr;
    arr.push_back(1);
    for(int multiplier = 2; multiplier= 0; i--){
    result.push_back(arr[i]);
    }
    return result;
    }
    };
    //{ Driver Code Starts.
    int main() {
    int t;
    cin >> t;
    while (t--) {
    int N;
    cin >> N;
    Solution ob;
    vector result = ob.factorial(N);
    for (int i = 0; i < result.size(); ++i){
    cout