Subsets | Simple Story To Code | Leetcode 78 | Recursion Concepts And Questions | Video 17

SdĂ­let
VloĆŸit
  • čas pƙidĂĄn 28. 07. 2024
  • iPad PDF Notes - github.com/MAZHARMIK/Intervie...
    Whatsapp Community Link : www.whatsapp.com/channel/0029...
    This is the 17th video of our playlist "Recursion Concepts And Questions". Find the Details below :
    Video Name : Subsets | Simple Story To Code | Leetcode 78 | Recursion Concepts And Questions
    Video # : 17
    C++/Java Code Link : github.com/MAZHARMIK/Intervie...
    Leetcode Link : leetcode.com/problems/subsets/
    GfG Problem Link : www.geeksforgeeks.org/problem...
    Note that we can also solve this using Bit-Magic which will be done in our Bit-Magic playlist.
    🔍 Unraveling Recursion: A Journey into the Depths of Code
    đŸŽ„ Welcome to the 17th Video of my Recursion Playlist! 🚀 In this enlightening video, we will solve a very famous recursion/backtracking problem "Subsets" with the help of Recursion. We will start with a Simple story understanding the problem by making a simple choice Diagram and then we will be Converting Story to code and writing the recursive code for the problem and also I will also be explaining the Time and Space Complexity of the code 🌐
    🔍 What's Inside?
    🔗 Simple story understanding with Subsets generation with a Choice Tree Diagram
    🔗 Converting Story to code and writing the recursive code for Subsets generation
    🔗 Explanation of Time and Space Complexity of the code
    đŸ‘©â€đŸ’» Who Should Watch?
    This playlist is for everyone but best suited for Freshers who are new to Recursion.
    🚀 Embark on the Recursive Adventure Now!
    My DP Concepts Playlist : ‱ Roadmap for DP | How t...
    My Graph Concepts Playlist : ‱ Graph Concepts & Qns -...
    My GitHub Repo for interview preparation : github.com/MAZHARMIK/Intervie...
    Subscribe to my channel : / @codestorywithmik
    Instagram : / codestorywithmik
    Facebook : / 100090524295846
    Twitter : / cswithmik
    Approach Summary : The approach used in the provided Java code is a recursive backtracking algorithm to generate all possible subsets of an input array. The algorithm explores two possibilities at each step: including or excluding the current element. This is achieved through the solve method, which, when called with a specific index, either adds the current element to the subset and makes a recursive call or skips the current element and proceeds with another recursive call. The base case terminates the recursion when the index exceeds the length of the array. The subsets are stored in the result list, and the space complexity is O(2^N) due to the storage of all possible subsets. The recursion stack space complexity is O(N), where N is the length of the input array, as each recursive call adds a new level to the call stack, and the depth of recursion is equal to the length of the array.
    ╔═╩╗╔╩╗╔═╩═╩╩╩╩╗╔═╗
    ║╚╣║║║╚╣╚╣╔╣╔╣║╚╣═╣
    ╠╗║╚╝║║╠╗║╚╣║║║║║═╣
    ╚═╩══╩═╩═╩═╩╝╚╩═╩═╝
    ✹ Timelines✹
    00:00 - Introduction
    0:09 - Motivation (Bhashan)
    0:47 - Problem Explanation
    1:56 - Options = Recursion
    3:08 - Tree Diagram
    7:46 - Time & Space Analysis from Tree Diagram
    12:22 - Recursion Magic - Trust (story to code)
    16:17 - What if we had duplicates
    20:17 - Coding Live on Leetcode
    #codestorywithMIK
    #coding #helpajobseeker #easyrecipes #leetcode #leetcodequestionandanswers #leetcodesolution #leetcodedailychallenge #leetcodequestions #leetcodechallenge #hindi #india #coding #helpajobseeker #easyrecipes #leetcode #leetcodequestionandanswers #leetcodesolution #leetcodedailychallenge #leetcodequestions #leetcodechallenge #hindi #india #hindiexplanation #hindiexplained #easyexplaination #interview#interviewtips #interviewpreparation #interview_ds_algo #hinglish #github #design #data #google #video #instagram #facebook #leetcode #computerscience #leetcodesolutions #leetcodequestionandanswers #code #learning #dsalgo #dsa #2024 #newyear #RecursionExplained #CodingJourney #Programming101 #TechTalks #AlgorithmMastery #Recursion #Programming #Algorithm #Code #ComputerScience #SoftwareDevelopment #CodingTips #RecursiveFunctions #TechExplained #ProgrammingConcepts #CodeTutorial #LearnToCode #TechEducation #DeveloperCommunity #RecursiveThinking #ProgrammingLogic #ProblemSolving #AlgorithmDesign #CSEducation

Komentáƙe • 31

  • @bhuppidhamii
    @bhuppidhamii Pƙed 2 měsĂ­ci +7

    came here to learn about subsets

  • @Dezy_Kri
    @Dezy_Kri Pƙed 2 měsĂ­ci +7

    solved today problem of the day!

    • @codestorywithMIK
      @codestorywithMIK  Pƙed 2 měsĂ­ci +2

      Awesome đŸ‘đŸ»

    • @shreshth1961
      @shreshth1961 Pƙed 6 dny

      @@codestorywithMIK sir subset with duplicates vala ki video bna di jiye plz

  • @wearevacationuncoverers
    @wearevacationuncoverers Pƙed 5 měsĂ­ci +1

    Thank you so much mik.
    I wanted to let you know, me and my friends are learning from your playlists and we play it on speaker and everyone sits and listen and make notes. Thank you so much again for doing so much for us.

  • @jahanvikumari7215
    @jahanvikumari7215 Pƙed 28 dny

    upload the video for duplicate elements also sir helpful for us

  • @yashkalia2311
    @yashkalia2311 Pƙed 2 měsĂ­ci +1

    Never stopppp working sir❀❀❀we are greatfull to have you

  • @8daudio672
    @8daudio672 Pƙed 2 měsĂ­ci +1

    Best thing i Got this year❀

  • @layathal7460
    @layathal7460 Pƙed měsĂ­cem

    Sir, why here temp.pop_back() is not given after the second recursive call? but given in 'generate paranthesis' question? When I removed the second pop back from generate paranthesis qn , it is not working. what is the difference between these two?

  • @a3rdtierguy864
    @a3rdtierguy864 Pƙed 2 měsĂ­ci +1

    Similar aayega to ek set bna lenge aur last me phir set ko vector me convert kar do that is the approach

  • @helloimjavauser
    @helloimjavauser Pƙed 5 měsĂ­ci

    Additionally, I enjoy watching your videos. They provide really good explanations. Thanks a lot for your efforts.

  • @Thriftinghai
    @Thriftinghai Pƙed 5 měsĂ­ci +1

    Your consistency is on another level.

  • @indian_tech6185
    @indian_tech6185 Pƙed 18 dny +1

    sir ek code ka dry run bhi kraa dete to or achay say smjh aata..btw thank you 💯👍

    • @codestorywithMIK
      @codestorywithMIK  Pƙed 18 dny

      Hi there.
      Feedback taken . I will take care of this thing in mind for future videos â€ïžđŸ™

  • @gauravbanerjee2898
    @gauravbanerjee2898 Pƙed 2 měsĂ­ci

    Thanks a lot bhaiya ❀❀

  • @ru45098
    @ru45098 Pƙed 5 měsĂ­ci +1

    i request you to complete the series ,dont put this on hold or stop the series.
    Amazing video as always

  • @technicalguy.
    @technicalguy. Pƙed 3 měsĂ­ci +2

    Exceptional Teaching ❀❀

  • @jeethora586
    @jeethora586 Pƙed měsĂ­cem

    What you did for not selecting a duplicate subset ? I m confused

  • @tosifkankod1300
    @tosifkankod1300 Pƙed měsĂ­cem +1

    bro keep making video like this

  • @GauravSingh-xx1bs
    @GauravSingh-xx1bs Pƙed 2 měsĂ­ci +1

    maza aagya yrr

  • @dayashankarlakhotia4943
    @dayashankarlakhotia4943 Pƙed 5 měsĂ­ci

    one error temp.add(nums[i]);

  • @abhaygupta6221
    @abhaygupta6221 Pƙed 5 měsĂ­ci

    Sir please make of today's GFG potd

    • @codestorywithMIK
      @codestorywithMIK  Pƙed 5 měsĂ­ci +2

      Take hint from this video. It will help to build the intuition for that also
      Find Critical and Pseudo-Critical Edges in Minimum Spanning Tree | Broken in Steps | Leetcode-1489
      czcams.com/video/gDPh7gsK3F8/video.html
      Let me know if that helps

    • @Area-fd8ht
      @Area-fd8ht Pƙed 5 měsĂ­ci

      Bhaiya @@codestorywithMIKpermutation 2 (leetcode 47) me bhi add kar do es series me plsđŸ™đŸ»đŸ™đŸ»đŸ™đŸ»

  • @pavankalyan9083
    @pavankalyan9083 Pƙed 4 měsĂ­ci +1

    I m here to watch your videos but disappointed because language is Hindi😱

    • @codestorywithMIK
      @codestorywithMIK  Pƙed 4 měsĂ­ci +1

      Apologies for the inconvenience đŸ„șâ˜č

  • @dayashankarlakhotia4943
    @dayashankarlakhotia4943 Pƙed 5 měsĂ­ci +1

    code for duplicate.
    public Listsubset WithDup(int[]nums){
    Listans=new ArrayList();
    Arrays.sort(nums);
    backtrack(0,ans,new ArrayList(),nums);
    return ans;
    }
    private void backtrack(int idx,Listans,Listtemp,int[]nums){
    ans.add(new ArrayList(temp));
    for(int i=idx;i0&&nums[i]==nums[i-1]) continue;
    backtrack(i+1,ans,temp,nums);
    temp.remove(temp.size()-1);
    }
    }
    đŸŽ‰â€