Ep9- Find all the UNIQUE permutations of an array | Recursion | DSA series | Codes in description.

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

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

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

    I am sorry guys for the delay.
    I was not feeling well, so took a nap.
    My father woke me up and said you have to upload, people will be waiting.
    Sorry, I will automate the process from tomorrow 😊.
    Enjoy the video.

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

      No problem #frazbhaii
      How are you feeling now??

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

      No problem bhaiyya
      stress mat lo ❤️

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

      Koi nahi bhai ❤️

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

      no issues bro, thanks for uploading 🙏

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

      No problem bhai. Ek request the aap se bhai leetcode par karao na problems

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

    bhaiya after your ep -8 I solved that question on leetcode and in ( similar question ) section this question .. literally tired of solving by own at end 15/20 test case passed ,,,,,,,,, thanku bhaiya ❤️❤️❤️❤️ for this videoooo u are hero

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

    Thankyou bhaiya for sharing your knowledge for free it was great to learn from you

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

    I am liking this series. Although I am weak in recursion, these videos are improving my thinking process. Keep it up. Good work.

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

    Day 9 Bhai keep it up we will gonna follow till the last day of the playlist.

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

    i think instead of using an extra data structure like set , we can use a while loop instead of for loop and keep track of repetitive elements .
    def printUniquePermutation(inp,out):
    if len(inp) == 0:
    print(out,end=' ')
    return
    i=0
    while i

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

    Great content as ever!! Learning a new way to generate all permutations by swapping instead of using a vector check.
    Thanks a lot for the series sir!!

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

      Thanks for writing bro

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

      @@LearnYardYT Welcome sir☺️

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

    Bro these types of manipulations in a question helps us to understand question much better ❤❤❤❤❤❤❤❤❤❤❤❤❤❤

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

      Thanks for writing ❤️❤️

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

    Wow, bhaiya absolutely great

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

    Bro excellent explanation same way I thought the solving of this question after doing the previous question

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

      So you are learning now

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

    Thanks again bhaiya....I was eagerly waiting and checking notification for Ep-9 video🤟🤟finally and gradually I am improving myself🙋‍♀️😎

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

      Thanks Shagun ♥️

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

    get well soon bhaiya !! hats off to your consistency

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

      Thanks for writing Yash

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

    Thanks for the video bro...
    Thanks for your time even in your tough situation
    Great
    Consistency ✌️✌️

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

      Thanks for writing bro ☺️

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

    to understand how the swap back function is able to give us the original string back can be confusing because we also have the perm(..) call in between, so we can lose count mentally, how many times we are forming swap. but we can understand it like this, inside perm we call an-original-swap then a perm, which can also perform an original swap. but when perm returns, the additional-swap will get operated. thus, jitne original-swap ho rhe hain, utne hi additional-swap.

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

    Thank You Bhaiya for the efforts, Take care of yourself..and we were waiting but it's fine, you can take your time.

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

    wonderful explanation

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

    Loved the lecture so much. But no more bothering comments for today. And yes a break is always necessary. Keep uploading with fresh mind ❤️. Love you

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

    Don't worry bhaiya, consistently roj video upload karna hi badi baat hai, always support you and salute your consistency bhiya.You r an inspiration for us.keep it up bhaiya 👍

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

      Thanks a lot for your words Isika.

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

    My Approach by using a freq array and to store the unique permutations I used a set
    #include
    void helper(vector &nums, vector &ds, set &ans, vector &freq){
    //base condition
    if (ds.size() == nums.size()){
    ans.insert(ds);
    return;
    }

    for (int i=0 ; i

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

    Very good explannation sir, but I've another approach..... what if we keep the code same and just change the base case.
    if(pos == arr.size())
    {
    auto it = find(ans.begin(), ans.end(), arr);
    if(it == ans.end())
    ans.push_back(arr);

    return ;
    }
    this is also giving the right answer. but gives TLE.

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

      because basically you are generating all the permutations here then for a single order you check if that is already present or not so you are checking for 2^n array permutations SO TLE

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

    Thanks for the lecture sir. Nice questions and content and well soon!!💖

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

      Thanks for writing ❤️

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

    lecture 9 Done :) ❤❤💛 waiting for next episode 👌👌👌👌👌👍👍👍💝

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

    Bro now u r well??
    #ep_9_done love u vaiya❣️❣️❤️ keep going,, we r always support u😇

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

      Yes feeling fresh again to start recording next episode

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

    Hi Fraz, in this lecture also we are getting the same echo in the background

    • @arjunyadav-kt5jr
      @arjunyadav-kt5jr 2 ปีที่แล้ว

      i hope you have replaced your device/earphone by now, or else you'd keep writing that under every video

  • @ShubhamKumar-vk5cd
    @ShubhamKumar-vk5cd 2 ปีที่แล้ว +1

    I tried this question yesterday.
    Sorted the array which helped me to skip duplicate values.
    Never thought about using sets.
    Elegant Code 100%

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

      😁 now you will never forget it

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

    Ep-9 completed 😊🤘

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

    Sir after doing code please dry run the code. It will give more clarity how code is working.

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

    I tried to solve it but now i got it.
    Thank you Bhaiya❣❣

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

      You're welcome, and thanks for writing

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

      @@LearnYardYT 🙏🙏

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

    Python codes are not working properly.
    Can you check with them
    Or intimate your team to check the codes before posting in GitHub.it was not properly compiled for episode 6,7,8 so far. Hope you will resolve the issue

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

    tanks bhaiya....waiting for new videos

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

    Thanks alot bhaiya ❣️❣️

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

    Ep9 also done successfully ✅

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

    very helpful 🙏🏻🙏🏻

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

    1st time recursion ache se smjh aa raha hai bhaiya. But aaj to bohot choti video hai. 2 question cover ho skte the

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

    Tq soo much bro for your efforts

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

    It is a better solution. We do not need set to solve it because set insert has time complexity of O(logn) due to which time complexity gets increased and it is simpler than using unordered_set. We can solve it using vector only. Below is the solution :-
    #include
    void permutation(string &str,int n,int i,vector &permut)
    {
    if(i==n-1)
    {
    permut.push_back(str);
    return;
    }
    else
    {
    for(int j=i;j

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

      We are taking unordered sets it's O(1) complexity only

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

      The solution above will not work. You can test it with the input abba. If you look at the first position, swapping swap(a,a) will work, swap(a,b) will work, and then swap(a,b) will also work. However, this should not work, because the permutations will be the same for this case and the previous case, so the condition is not rejecting this case. To get the correct solution, we have to keep track of each position and avoid the case where the same position already had the element that we will get after the swap.
      if(i!=j && str[i]==str[j])
      {
      continue;
      }
      So keeping a set for each position(i) in the permutation function is the correct way to solve the problem.

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

      @@bishnoiankita729 I ran the program in the codestudio for all test cases it passed.

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

    nicely explain 🙌

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

    DSA series is 🔥🔥

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

    Another approach Bhaiya
    #include
    void perm(vector &ans, vector &arr, int pos)
    {
    if(pos == arr.size())
    {
    ans.push_back(arr);
    return ;
    }
    for(int i=0; i

    • @097sreesivaranjini7
      @097sreesivaranjini7 2 ปีที่แล้ว

      why the iteration is starting from 0??. i=pos...should be there right

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

    Awesome content bhai 👏

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

    sir you are the best

  • @Sandeep-zd6dq
    @Sandeep-zd6dq 2 ปีที่แล้ว

    Bhaiya I always gets confused between unique permutation and combination question, so please in next video please give the deep understanding of both so that we can find differences between them.

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

    I was waiting but not a problem
    Take care

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

    Instead of using sets can i simply check
    If( i! =pos and str[i] == str[pos])
    continue ;
    That will be okay right?
    BTW thank you for this series. I have just started dsa and you are helping me a lot.
    Although this course is for placement preparation but i liked the way of your teaching from the basic.

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

    #ep_9 done ✅✅
    We are with you bhaiya
    Keep making 🔥🔥

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

    Take care of your health brother
    May Allah Cure you
    Ameen
    And Also thanks to your father for caring about us❤❤❤

  • @Abhishek-fo3fc
    @Abhishek-fo3fc 2 ปีที่แล้ว +1

    Done understood ❤️✅

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

    #day 9 great explaination as always

  • @Gauravkumar-kc6xh
    @Gauravkumar-kc6xh 2 ปีที่แล้ว

    Great

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

    Good Video

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

    nice explain sir.

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

    Done 🔥Thankyou

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

      You're welcome ❤️❤️

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

    Get well soon bhaiya...

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

    day 9 done
    ❤️🙌

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

    Well explained 🤗🤗

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

    fav poet- Amhed Fraz
    fav teacher- Mohd Fraz

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

    Day 9 💯💯

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

    Done!! Thank you

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

    SC should be O(n^2) as we are using new unordered_set in every rec call?

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

    you can also use a find method inside if condition(base condition) to check if the vector already exist in ans, if not then insert else return
    if(find(ans.begin(), ans.end(), v)==ans.end()){ //i.e. does not exist, reached till end
    ans.push_back(v);
    }
    return;

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

    #Day_9
    Consistency_OP 🔥🔥🔥

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

    Please make video on how to code in geeks for geeks platform for bigenner

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

    Present ! ✔🙌

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

    Thanks sir

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

      You're welcome ♥️

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

    Logic:
    bring all the remaining elements in the array to the position and ask the recursion to perform the remaining task
    code:
    def permute(nums,pos,ans):
    track = []
    if pos == len(nums) - 1:
    ans.append(nums[:])
    return

    for i in range(pos,len(nums)):
    if nums[i] in track:
    continue
    track.append(nums[i])
    nums[i],nums[pos] = nums[pos],nums[i]
    permute(nums,pos+1,ans)
    nums[i],nums[pos] = nums[pos],nums[i]
    nums = [1,2,2]
    ans = []
    permute(nums,0,ans)
    print(ans)

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

    Can we get java equivalent code for the actual problem?

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

    completed👍

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

    Ya done completed bhaiya

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

    Watched episode 9!

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

    🔥

  • @Raj-pi1pl
    @Raj-pi1pl 2 ปีที่แล้ว

    L-9 done

  • @Empower-YouTube
    @Empower-YouTube 2 ปีที่แล้ว +1

    Team can anyone send me java code for this practise problem

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

    aaj 1 hr late post kyu hua , i was waiting

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

      Sorry bro

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

      @@LearnYardYT no worries, u were not feeling well , there is no problem

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

    Lecture 9 Completed ☑
    #dsabyfaraz💯
    #recursion❤

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

    Concepts are clear but when it comes to solve the problem by own 🥲

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

    bhaiya i want to ask that are these codes fully optimized?

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

    Why this code is not working??

    #include
    #include
    using namespace std;
    class Solution {
    public:
    void permu(vector &arr, vector &ans, int idx, int n) {
    if (idx == n) {
    ans.push_back(arr);
    return;
    }
    for (int i = idx; i < n; i++) {
    if (i != idx && arr[i] == arr[i - 1]) continue; // Skip duplicates
    swap(arr[i], arr[idx]);
    permu(arr, ans, idx + 1, n);
    swap(arr[i], arr[idx]);
    }
    }
    vector uniquePerms(vector &arr, int n) {
    vector ans;
    sort(arr.begin(), arr.end());
    permu(arr, ans, 0, n);
    return ans;
    }
    };

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

    Done✅

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

    bhaiya i got some error so where can i send u message picture

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

    Present #frazbhaii (EP9)

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

    everything is great but dry run part is missing

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

    fraz bhai long format videos dalo plz 8-10 minute ki videos dekhne mei mja nhi aata

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

      Long bhi ho jaengi videos aage

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

    class Solution {
    public:
    void permuteUniqueUtil(int idx, vector &ans, int n, vector &nums){
    if(idx >= n){
    ans.push_back(nums);
    return;
    }
    for(int i=idx; i

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

    Bhaiya geeks for geeks me code kar ne se phele Jo code likhe hua hote hai use kaise samjhe

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

    Episode-9 done

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

    First comment😊

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

    Please post 1hr+ video otherwise the course will take 7-8 months to compplete

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

      Length will increase in future lectures.

  • @Lucifer-xt7un
    @Lucifer-xt7un 2 ปีที่แล้ว

    Consistency ++

  • @25-cse-csmohitkumarmandal59
    @25-cse-csmohitkumarmandal59 2 ปีที่แล้ว

    Bhaiya I m in 1st year ,and I am watching it but I couldn't able to understand from power set problems...

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

    sir, your voice was echoing a bit