Print Subsets | Print PowerSets | Print all Subsequences

  Рет қаралды 188,803

Aditya Verma

Aditya Verma

Күн бұрын

Print all subsets of a String.
Problem Description: practice.geeks...
Link: / adityaverma
Video Pdf Notes: / 38704785 .
------------------------------------------------------------------------------------------
Here are some of the gears that I use almost everyday:
🖊️ : My Pen (Used in videos too): amzn.to/38fKSM1
👨🏻‍💻 : My Apple Macbook pro: amzn.to/3w8iZh6
💻 : My gaming laptop: amzn.to/3yjcn23
📱 : My Ipad: amzn.to/39yEMGS
✏️ : My Apple Pencil: amzn.to/3kMnKYf
🎧 : My Headphones: amzn.to/3kMOzM7
💺 : My Chair: amzn.to/385weqR
🛋 : My Table: amzn.to/3kMohtd
⏰ : My Clock: amzn.to/3slFUV3
🙋🏻‍♀️ : My girlfriend: amzn.to/3M6zLDK ¯\_(ツ)_/¯
PS: While having good gears help you perform efficiently, don’t get under the impression that they will make you successful without any hard work.

Пікірлер: 330
@divyamgarg3944
@divyamgarg3944 2 жыл бұрын
Sir I was struggling to get some confidence to solve a new recursive problems and I literally watched many videos on recursion but never got the intuition but when I watched your recursion and dp... Playlist I am able to get the intuition for any new recursive problem. I can't explain how much gratitude I've for you but still thanks alot Sir :) Really admire your hard work
@rishabhsingh5816
@rishabhsingh5816 4 жыл бұрын
best programming content on youtube or on any platform.. nobody can match u... bhai recursion pdha rhe ho..next backtracking pdha dena..maza aa jaega
@PIYUSH-lz1zq
@PIYUSH-lz1zq 2 жыл бұрын
Backtracking kaha se padha hai bhai
@vivekgoswami1474
@vivekgoswami1474 2 жыл бұрын
@@PIYUSH-lz1zq backtracking kha se pdha bhai?
@SohelDarwajkar
@SohelDarwajkar 6 ай бұрын
​@@vivekgoswami1474backtracking kaha se padha bhai?
@vivekgoswami1474
@vivekgoswami1474 6 ай бұрын
@@SohelDarwajkar backtracking ko bhi video daal d inhone check
@SohelDarwajkar
@SohelDarwajkar 6 ай бұрын
@@vivekgoswami1474 are ik but I just wanted to continue that flow of que with 1 year gap lmaooo..See the first comment was 3 yrs back then second was 2,3rd was 1 and mine was -1 yr 😅..
@AdityaKumar-pp4xw
@AdityaKumar-pp4xw 3 жыл бұрын
I can say this with utmost confidence those insignificant amount of dislikes are from people who have not watched and performed previous videos of this playlist, otherwise this is the GOAT recursion course!
@PIYUSH-lz1zq
@PIYUSH-lz1zq 2 жыл бұрын
Backtracking kaha se padha hai bhai
@PIYUSH-lz1zq
@PIYUSH-lz1zq 2 жыл бұрын
And greedy
@AdityaKumar-pp4xw
@AdityaKumar-pp4xw 2 жыл бұрын
@@PIYUSH-lz1zq prateek narang dsa course on udemy
@PIYUSH-lz1zq
@PIYUSH-lz1zq 2 жыл бұрын
is this applicable for numbers ???
@PIYUSH-lz1zq
@PIYUSH-lz1zq 2 жыл бұрын
@@AdityaKumar-pp4xw is this ques applicable for numbers ???
@hiteshsondhi
@hiteshsondhi 2 жыл бұрын
Aditya, this is some different level of coding and so easy to understand especially for confusing topic like Recursion. First time I understand why people say to have "leap of faith" while solving recursion... Kudos to your efforts
@vivekchaudhary1768
@vivekchaudhary1768 4 жыл бұрын
Bhai adiya verma, bhagwan tujhe lambi umer de. first time aise vedio mili hai jisme itna sahi btaya hai
@mehulgarg7253
@mehulgarg7253 Ай бұрын
both striver bhai and aditya bhai is dsa guru but guys seriously aditya bhai recursive playlist is more better than striver,btw striver recursion playlist also too good but aditya bhai recursion playist is just love....
@akarshjaiswal1622
@akarshjaiswal1622 4 жыл бұрын
As you said in first video... Writing the code was really a cakewalk ! ❤️❤️
@TheAdityaVerma
@TheAdityaVerma 4 жыл бұрын
Haha thanks, do share with your friends and help the channel grow !!
@chesteriglesias1025
@chesteriglesias1025 4 жыл бұрын
Bro please make BACKTRACKING videos.Your explanations are unanimously best on KZfaq.Thanks a lot man❤️
@yashpatel-dx8wr
@yashpatel-dx8wr 4 жыл бұрын
You are doing great please go forward so that we can get more benefits and thanks for sharing your knowledge freely 🙌🙌😁
@shishirkakhandki9230
@shishirkakhandki9230 3 жыл бұрын
I could not find any other tutorial explaining intuition behind recursive tree solutions. This is the the only one. Thanks a ton!
@PIYUSH-lz1zq
@PIYUSH-lz1zq 2 жыл бұрын
is this applicable for numbers ???
@rishikumar-rk7tk
@rishikumar-rk7tk 4 жыл бұрын
Watched all videos of every playlist Till now and waiting for more.. Thankyou for making such an important channel
@sammyj29
@sammyj29 3 жыл бұрын
Thanks to humme bolna chahiye __/\__ I have had difficulty in understanding recursion but thanks to you, I am improving with every day.
@susrandomguy
@susrandomguy 2 жыл бұрын
Broooo the way you explain the solution is something else🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥
@surbhitamrakar1638
@surbhitamrakar1638 4 жыл бұрын
A very happy teachers day to the best teacher Aditya sir..you are the best teacher I ever had..you made recursion so easy I can't even thought.hope the almighty bless you with lots of happines and growth..😊😊
@anuragnama5310
@anuragnama5310 4 жыл бұрын
Java Code private static void permutationFind(String input, String output) { if(input.length()==0){ System.out.println(output); return; } String out1 = output; String out2 = output; out2 += input.charAt(0); input = input.substring(1); permutationFind(input,out1); permutationFind(input,out2); }
@prashanthpalakurthi8439
@prashanthpalakurthi8439 4 жыл бұрын
Tnx bhai
@NotNotNithin
@NotNotNithin 3 жыл бұрын
out1 is redundant. You can remove it.
@surajpatil3247
@surajpatil3247 3 жыл бұрын
thanks bro
@Sunil_gora
@Sunil_gora 3 жыл бұрын
tysm bhai java mein code likh diya kro if possible
@divyanshmishra8615
@divyanshmishra8615 3 жыл бұрын
brother although the code works fine idk how.......but i have a serious doubt since op1 and op2 are two new strings created from op before every call to smaller input , i think we shud create a new String ip too because after the recursion call is over after ip.length == 0 how will the original string backtrack ??
@sagardas4569
@sagardas4569 4 жыл бұрын
Sachme vaiya apke vdo ki starting k music sei ek motivation milti he❤️
@AyushRanjan-kh4im
@AyushRanjan-kh4im Жыл бұрын
code for c++ vectorm; void solve(vector nums,vector op, vector &m) // m ko by address paas kiye as jo bhi changes m me ho wo vector wale fn me reflect ho and nums aur op ko pass by value kiye uska changes vector fn me reflect nahi hoga { if(nums.size()==0) { m.push_back(op); return; } vectorop1=op; vectorop2=op; op2.push_back(nums[0]); nums.erase(nums.begin()+0); solve(nums,op1, m); solve(nums,op2, m); } vector subsets(vector& nums) { vector m; vectorop; solve(nums,op,m); return m; }
@HarshSingh-lc2ct
@HarshSingh-lc2ct Жыл бұрын
Nice
@sunilsaikumar7030
@sunilsaikumar7030 2 жыл бұрын
Python 3 Code Time Complexity - O(2**N) Space Complexity - O(1) [Excluded Auxilary Stack Space] Code: def generateSubsets(Input): def helper(Op, In): if(In == ""): print(Op) return Op2 = Op Op2 += In[0] In = In[1:] helper(Op, In) helper(Op2, In) helper("", Input) Input = "abc" generateSubsets(Input)
@randomthoughts3533
@randomthoughts3533 3 жыл бұрын
Once again thanks Again. did saw the code in video just watched the tree part and design the code by myself. and did little tweak to avoid extra variable. and here it like you said cakewalk. thanks Aditya. posting the code also in java. static void subSet(String op, String ip) { if (ip.length() == 0) { System.out.println(op); return; } subSet(op, ip.substring(1, ip.length())); subSet(op + ip.substring(0, 1), ip.substring(1, ip.length())); }
@manshushivam295
@manshushivam295 2 жыл бұрын
AWesome
@Hirxn.vaghela
@Hirxn.vaghela 3 жыл бұрын
when he said "The guy who made dp/recursion easy". He really ment it!!!
@PIYUSH-lz1zq
@PIYUSH-lz1zq 2 жыл бұрын
is this applicable for numbers ???
@NewBIE-xz5jm
@NewBIE-xz5jm 7 ай бұрын
Did myself in 15 min! thanks bro!
@abhishekdwivedi-ll5ky
@abhishekdwivedi-ll5ky 2 жыл бұрын
Best teacher for coding
@jayachandradora5668
@jayachandradora5668 4 жыл бұрын
@Aditya Verma, Videos are very interesting and never forgot your teaching style... Thanks a lot keep going... Please upload some graph related videos.
@ishwaripednekar5164
@ishwaripednekar5164 2 жыл бұрын
Best Print all subset solution till now ❤️
@PIYUSH-lz1zq
@PIYUSH-lz1zq 2 жыл бұрын
is this applicable for numbers ???
@Neerajkumar-xl9kx
@Neerajkumar-xl9kx 3 жыл бұрын
at end of the video also mention time and space complexity..it will be useful for all of us.thank u
@gaurav2010kumar
@gaurav2010kumar 2 жыл бұрын
recursion jaadu hai bhai .. Thanks a lot brother! you are the best! Please add graphs playlist as well
@farzanaiqbal3768
@farzanaiqbal3768 4 жыл бұрын
Please do a video on: Print all permutations of a string!
@shivamagrawal3542
@shivamagrawal3542 3 жыл бұрын
use backtracking
@abhinandanb3591
@abhinandanb3591 3 жыл бұрын
@@shivamagrawal3542 how
@souravmajumder6598
@souravmajumder6598 4 жыл бұрын
Glad to see your lecture brother👌 Take love from Bangladesh ❤🇧🇩
@nehaagarwal6544
@nehaagarwal6544 4 жыл бұрын
Can you please tell us the order of the upcoming topics like will you be teaching backtracking or graphs or trees. It will be helpful for us and will give us clarity.
@madhurimasen7086
@madhurimasen7086 3 жыл бұрын
this is the best explanation I have ever seen!
@rajattalnikar6167
@rajattalnikar6167 4 жыл бұрын
Please Next Question -> Phone Keypad Combinations print.
@TheAdityaVerma
@TheAdityaVerma 4 жыл бұрын
thats backtracking bro, I will cover that in backtracking.
@rajattalnikar6167
@rajattalnikar6167 4 жыл бұрын
@@TheAdityaVerma Cool. Will wait for Backtracking Series.
@anonymous-kl1un
@anonymous-kl1un 4 жыл бұрын
@@TheAdityaVerma bro backtracking 13th se pehle acche se samjhado please
@sanjeevkumarnirmal5316
@sanjeevkumarnirmal5316 3 жыл бұрын
@@TheAdityaVerma Sir please next Playlist Backtracking pe bana dijiye🙏🙏.
@sameerchoudhary8590
@sameerchoudhary8590 3 жыл бұрын
@@TheAdityaVerma Backtracking and graph please
@UECDishaKhattri
@UECDishaKhattri 4 жыл бұрын
@Aditya verma thanks a lot for removing the fear of recursion !! Before your videos, I used to avoid recursion wherever possible. Can you please suggest something on where to use the return statement generally in any question.
@VishalSharma-vb9qd
@VishalSharma-vb9qd 2 жыл бұрын
The above subset question can be written in the following way also if(base condition) { .... } else { recursion call induction } but we have written like this if(base condition) { ... return // so that we don't execute further operations } recursion call induction It makes the code more readable and nice. Just remember that you can use return whenever you don't want to perform further operations in the function. How we use continue in the loop - so that further code is not executed and loop starts with next counter... I hope I was able to explain.
@ShubhamKumar-xs7ul
@ShubhamKumar-xs7ul 4 жыл бұрын
bhaiya please add questions on binary trees which is totally dependent on recursion. Thanks
@mridulgupta8144
@mridulgupta8144 4 жыл бұрын
Problem: Product of Array Except Self btw, Great content, thanks! :)
@whysoserious-yj1ku
@whysoserious-yj1ku 3 жыл бұрын
Bro you need to do preprocessing in this. Keep lets say a vector prod_ahead, where prod_ahead[I] = product of all elements from arr[I + 1] to last element, ( prod_ahead[n - 1] = 0 ) and then in another iteration, keep storing running_product such that running_prod at ith iteration is product of all elements left to i. then in the result vector, keep storing prod_ahead[I] * running_sum
@vibhorsoni8517
@vibhorsoni8517 3 жыл бұрын
bhai feel dila de recursion ke , thanks a lot bhai
@nikitachaudhari2800
@nikitachaudhari2800 3 жыл бұрын
Most liked youtuber of mine❤️
@akashjain4281
@akashjain4281 4 жыл бұрын
Keep the good work going ! Amazing videos. 👍😃
@arpanbanejee5143
@arpanbanejee5143 3 жыл бұрын
bas ek step tak chalakar dekh lenge IP-OP method main bhi? fir use hisab se likh denge code, baki apne aap kam kar jaega! pls correct me if I am wrong! Awesome way to explain man!
@siddhantrai7613
@siddhantrai7613 3 жыл бұрын
Hi brother, make a video on proper use of returns in recursion, most of the time I am out of clue when it comes to returns statement usage. That will be a great help. Thank you
@kanhaiyatulsyan7560
@kanhaiyatulsyan7560 3 жыл бұрын
i have same problem and commented the same in most of his videos but no reply
@monitranjan6867
@monitranjan6867 Ай бұрын
@@kanhaiyatulsyan7560 Basically ip length is zero right, ip is empty and if you wont write return that would mean recursion gonna be working again on the input, but this time its empty right? and in our code we are accessing ip[0] index which doesn't exist, which means it's a invalid memory access, and that would most probably leads to segmentation fault.
@ChandraShekhar-by3cd
@ChandraShekhar-by3cd 4 жыл бұрын
Thanks for the detailed explanation. Plesse could you make us undersatntd that what is the importance of the "return " statement and how missing it will cause a segmentation fault .Thanks
@TheAdityaVerma
@TheAdityaVerma 4 жыл бұрын
Basically ip length is zero right, ip is empty and if you wont write return that would mean recursion gonna be working again on the input, but this time its empty right? and in our code we are accessing ip[0] index which doesn't exist, which means it's a invalid memory access, and that would most probably leads to segmentation fault.
@ChandraShekhar-by3cd
@ChandraShekhar-by3cd 4 жыл бұрын
@@TheAdityaVerma Thanks Aditya, Got the point now..Thank you
@ashisharora186
@ashisharora186 4 жыл бұрын
Thanks for such detailed explanation. One small suggestion from my side : "Try Using Dark theme Mode" a lot of the students like me watch your videos at night, and dark theme will be easy on the eyes. Thanks you once again you're doing an amazing work :)
@anandpandey918
@anandpandey918 Ай бұрын
/* * Subarray: * 1: Contiguous * 2: Order of appearence is maintained * 3: Every subarray is a subset. * 4: Every subarray is a subsequence * 5:For an array/string of size n, we can have ( (n*(n+1))/2 + 1 ) Subarray in * total i.e (n*(n+1))/2 non-empty subarray + 1 Empty subarray. * * Subsequence: * 1: May or may not be contiguous * 2: Order of appearence is maintained. * 3: Derived by deleting some or none of the elements of the sequence without * changing the order of * the remaining elements. * 4: Every subsequence is subset. * 5: For a sequence/array/string of size n, we can have 2^n Subsequence in * total i.e ((2^n)-1) non-empty sub-sequences + 1 Empty Subsequence. * * Subset: * 1 : May or maynot be contiguous * 2: Order of appearence may or may not be maintained. * 3: Subsets and subsequence ae exactly same thing the only difference between * them is that subsequence should maintain order of appearence of elements * while subsets don't need to preserve order of appearence of elements * for ex : {1,2} and {2,1} represent the same subset however while * writing/listing the subsets of the sets you can either write {1,2} or {2,1} * it doesnot matter but you can not list both at the same time * since they are exactly the same thing. * * Ex: arr[]={1, 2, 3} * * Subarrays : * * [1] * [1,2] * [1, 2, 3] * [2] * [2,3] * [3] * * * Subsequences: * * [] * [1] * [1, 2] * [1, 3] * [1, 2, 3] * [2] * [2, 3] * [3] * * Subsets: * * [] * [1] * [1, 2] or [2, 1] * [1, 3] or [3, 1] * [1, 2, 3] or [1, 3, 2] or [2, 3, 1] or [2, 1, 3] or [3, 1, 2] or [3, 2, 1] * [2] * [2, 3] or [3, 2] * [3] */ //Iterative Approach //Method 1 : /* For arr[] = {1, 2, 3}: Intially: subsets :[[]]. (Add an empty subset) Iteration 1: (arr[0]=1) Pair 1 with all existing subsets i.e [1] subsets: [[],[1]] Iteration 2: (arr[1]=2) Pair 2 with all existing subsets i.e [2] and [1, 2] subsets: [[], [1], [2], [1, 2]]. Iteration 3: (arr[2]=3) Pair 3 with all existing subsets i.e [3], [1, 3] , [2, 3] and [1, 2, 3] subsets: [[], [1], [2], [1, 2], [3], [1, 3], [2, 3], [1, 2, 3]]. */ class Solution { public List subsets(int[] arr) { List subsets = new ArrayList(); subsets.add(new ArrayList()); // Start with the empty subset for (int val : arr) { int size = subsets.size(); for (int i = 0; i < size; i++) { // Create a new subset from the existing subsets by adding the current number to // it List subset = new ArrayList(subsets.get(i)); subset.add(val); subsets.add(subset); } } return subsets; } } // Method 2 : Bit Manipulation /* * For example : arr[] = {1, 2, 3, 4}; there are 16 (i.e 2^4) sub-sequences. * If we carefully notice it is nothing but binary numbers from 0 to 15 which * can be shown as below: * * 0000 {} * * 0001 {1} * * 0010 {2} * * 0011 {1, 2} * * 0100 {3} * * 0101 {1, 3} * * 0110 {2, 3} * * 0111 {1, 2, 3} * * 1000 {4} * * 1001 {1, 4} * * 1010 {1, 4} * * 1011 {1, 2, 4} * * 1100 {3, 4} * * 1101 {1, 3, 4} * * 1110 {2, 3, 4} * * 1111 {1, 2, 3, 4} * * * Starting from right,whenever we encounter set bit(1) in a number at ith * position the we print the element present at (i-1)th index in the array. */ // Intuitive Implementation class Solution { public List subsets(int[] arr) { List subsets = new ArrayList(); // Total number of subsets is 2^n int totalSubsets = 1
@dhirendrapratapsingh8283
@dhirendrapratapsingh8283 4 жыл бұрын
Sir Your Video are really worthy and denote your true hardwork behind it. But Please try to release your series in an order from easy to hard. Do number them if necessary.
@grovestreet9165
@grovestreet9165 4 жыл бұрын
bhai mai normally comment nahi karta but thanks bro i will surely support you on pateron when i'm able to make enough money to support you
@rishabsharma5307
@rishabsharma5307 4 жыл бұрын
zindagi mein pheli bar smjh mein aaya hai
@avishjain4281
@avishjain4281 2 жыл бұрын
instead of erase function we can just pass ip.substr(1); it returns the string remaining after the first element
@SatyamKumar-bw4vi
@SatyamKumar-bw4vi 2 жыл бұрын
Hare Krishna!🙏🙏 Great Work
@rohitnandagawali1589
@rohitnandagawali1589 2 ай бұрын
for leetcode question [aditya verma method], array as input void subset1(vector ip, vector op,vector& ans){ if(ip.size()==0){ ans.push_back(op); return; } vector output1=op; vector output2=op; output2.push_back(ip[0]); ip.erase(ip.begin()+0); subset1(ip,output1,ans); subset1(ip,output2,ans); } vector subsets(vector& nums) { vector op={}; vector ans; subset1(nums, op, ans); return ans; }
@ankoor
@ankoor 4 жыл бұрын
Python Code (LC Subsets) def subsets(A, output, result): if len(A) == 0: output.append(result) return L = result[:] R = result[:] R.append(A[0]) A = A[1:] subsets(A, output, L) subsets(A, output, R) A = [1, 2, 3] output = [] result = [] subsets(A, output, result) print(output)
@saikatbanerjee7273
@saikatbanerjee7273 4 жыл бұрын
This code is having problem
@parthdesai1108
@parthdesai1108 3 жыл бұрын
@@saikatbanerjee7273 def solve(op,ip): if len(ip)==0: print(op, end =" ") return op1=op op2=op op2+=ip[0] ip=ip[1:] solve(op1,ip) solve(op2,ip) return string="ab" solve("",string)
@nero-kun-here
@nero-kun-here 4 жыл бұрын
Thank you so much for this great playlist.
@thetravelers937
@thetravelers937 2 жыл бұрын
time complexity is o(2^n) .am i right ??
@_ApoorvaShinde
@_ApoorvaShinde 3 жыл бұрын
Thanks for making recursion so easy!
@sayasark
@sayasark 2 жыл бұрын
Wonderfully explained!! thank you.
@endlessloopsoftwares4724
@endlessloopsoftwares4724 3 жыл бұрын
Bhaut mast smjhaya bhai!!
@bommakantibeeraiah1486
@bommakantibeeraiah1486 4 ай бұрын
is can we able to do with array because we are not able to small the input with array?
@Khabibullah
@Khabibullah 4 жыл бұрын
Bhai aapka Flipkart and Nutanix interview experience share kab karoge.
@dhvaneshshah7820
@dhvaneshshah7820 3 жыл бұрын
Thank you Bhai, bohot hi easy understanding k sath problem samjadi aapne...! keep it up! Here is my python code def subsets(self, nums: List[int]) -> List[List[int]]: self.res = [] op = [] ip = nums self.solve(ip, op) return self.res def solve(self, ip, op): if (not ip): self.res.append(op) return op1 = op[:] op2 = op[:] op2.append(ip[0]) ip = ip[1:] self.solve(ip, op1) self.solve(ip, op2)
@nikitajaiswal9112
@nikitajaiswal9112 2 жыл бұрын
Can u explain meaning of op[:]
@sankalparora9374
@sankalparora9374 Жыл бұрын
Way better Sound quality in this one.
@KshitijKumarOfficial
@KshitijKumarOfficial 6 ай бұрын
class Solution { private: // To solve this first draw Recursive tree then code it void solve(vector& ans,int index,vector nums,vector output) { // base case if(index>=nums.size()) { ans.push_back(output); //before returning we have to push the output in ans return; } /* note pahle exclude ka recursion call krenge uske baad include krenge elements ko nahi toh pahle hi elements include ho jayenge toh ans me original array hi print hote rahega */ // exclude that element and Recursion call solve(ans,index+1,nums,output); // include that element int element=nums[index]; output.push_back(element); // Recursion call => Includded R.C solve(ans,index+1,nums,output); } public: vector subsets(vector& nums) { vector ans; vector output; int index=0; solve(ans,index,nums,output); // we create this function for recursive call bcz we have to pass each time (ans,index,nums,outpu)t and not returning anything only have to update the ans; return ans; } }; // thanks me later
@udaypandey5659
@udaypandey5659 2 жыл бұрын
java - solution public class PowerSet { public static void main(String[] args) { String ip = "abc"; String op = ""; subset(ip,op); } private static void subset(String ip, String op) { if(ip.length()==0) { System.out.println(op); return; } String op1 = op; String op2 = op +ip.charAt(0); ip = ip.substring(1); subset(ip, op1); subset(ip,op2); } }
@priyanshkumar_iitd
@priyanshkumar_iitd 8 ай бұрын
Thanks ! Awesome Explanation...
@mayank8
@mayank8 3 жыл бұрын
thanks a lot for explaining so beautifully
@PIYUSH-lz1zq
@PIYUSH-lz1zq 2 жыл бұрын
is this applicable for numbers ???
@yugamverma8403
@yugamverma8403 7 ай бұрын
//Java Recursive functiion of this code static void solve(String input,String output){ if(input.length() == 0){ System.out.println(output); return; } //now take 1st char of input string char ch = input.charAt(0); //take char at 0th index of input string solve(input.substring(1),output + ch); //ignore char at 0th index of input string solve(input.substring(1),output ); }
@princegarg1086
@princegarg1086 4 жыл бұрын
bhaiya please make video on Asymptotic notations and time complexity and space complexity
@pranshukashyap6848
@pranshukashyap6848 4 жыл бұрын
Please DP ki playlist pure Complete kardo.. LIS, Kadanes's wagera bache hain.. Plz next usse complete kardo..
@Prateek_Mantry
@Prateek_Mantry 4 ай бұрын
thank you.
@gauranshverma4364
@gauranshverma4364 4 жыл бұрын
bhaiya can you provide us with a list of practice questions of about 20-30 questions,it would be very much helpful ..as there are thousand of questions there on the internet
@bharatadk
@bharatadk Жыл бұрын
Python Implementation........ def subsets(self, nums: List[int]) -> List[List[int]]: output = [] def helper_fun(start,temp,output): output.append(temp) for i in range(start,len(nums)): helper_fun(i+1,temp + [nums[i]],output) helper_fun(0, [],output) return output
@nitishkumar-mz7cr
@nitishkumar-mz7cr 3 жыл бұрын
the same can be done with vector right? means to get all subsets of int array
@PIYUSH-lz1zq
@PIYUSH-lz1zq 2 жыл бұрын
is this applicable for numbers ???
@rishabhinc2936
@rishabhinc2936 2 жыл бұрын
@@PIYUSH-lz1zq its not working can u help wih soln
@kronizerdeltap8318
@kronizerdeltap8318 4 жыл бұрын
bhaiya, kya aap Graph series bhi upload karoge? aapka padhaya hua bohot acche se samajh mein aata hai, pls graphs bhi upload kardena
@harishrawat1205
@harishrawat1205 4 жыл бұрын
yaar apna bhai jis sequence m videos daal rha hai wo usne prioritise kre hue hain...he knows what is more important and trying to help us master those concepts first! So just stick with him! He'll eventually cover graphs.
@vikashkumarchaurasia1299
@vikashkumarchaurasia1299 4 жыл бұрын
awesome explaination bro. thanks
@satyamgupta5423
@satyamgupta5423 Жыл бұрын
#include using namespace std; void subsets(string input,string output){ if(input.size()==0){ cout
@sayantaniguha8519
@sayantaniguha8519 3 жыл бұрын
Okayyy.. So, Smaller input will be same for all common nodes of a common generation? Hona vi chahiye... its so obvious .. haina
@kishanmishra9802
@kishanmishra9802 4 жыл бұрын
Great teacher
@kiran4400
@kiran4400 3 жыл бұрын
HEY, thank u for such a great explanation, only one doubt, can't we keep output as one variable instead of taking two different op1 and op2?
@mukulbansal8269
@mukulbansal8269 2 жыл бұрын
yes we can but for beginners taking two outputs will be good for better understanding.
@PIYUSH-lz1zq
@PIYUSH-lz1zq 2 жыл бұрын
is this applicable for numbers ???
@MOHITRANA-to7rf
@MOHITRANA-to7rf 2 жыл бұрын
@@PIYUSH-lz1zq input them as string or to take the last element use % and for first use // floor remember cpp // treated as comment so google floor
@AyushKumar-po8no
@AyushKumar-po8no 4 күн бұрын
It does not work for array like ip: [1,2] and op: [[], [1], [2], [1,2]]
@neharikakhera6411
@neharikakhera6411 4 жыл бұрын
Thanks .. great explanation
@shashankmishra6705
@shashankmishra6705 20 күн бұрын
how to memoize this. I am getting TLE on large test cases.
@Sauravk2107
@Sauravk2107 Жыл бұрын
If we call recursive function first on op1 and then op2 , it gives error . Why??
@pradnyeshmali4207
@pradnyeshmali4207 2 жыл бұрын
how would you deal with negative number? it's taking -sign as a character...
@anonymous-kl1un
@anonymous-kl1un 4 жыл бұрын
Bro backtracking aaegi? Yaa nahi? Please bata do
@kushagrasaxena8831
@kushagrasaxena8831 4 жыл бұрын
Recursion OP!
@_AnkitOjha
@_AnkitOjha 3 жыл бұрын
bhai ap kahi bhagwan nhi ho n ,glti se prithvi pe aa gye ho , kyoki itne ache se insan to sikha nhi skta hai
@zoraiznaeem2579
@zoraiznaeem2579 4 жыл бұрын
@Aditiya how is input/output method different than choice diagram(dp)? In both we either choose to have it in the output of not... Is it just that one has optimal substructure and other has not?
@shriyajaswani3400
@shriyajaswani3400 3 жыл бұрын
Aditya bhaiya number repeat ho sakte hai tab kese karenge?? October leetcode challenge ka second question hai....
@deeproy7292
@deeproy7292 4 жыл бұрын
bhaiya you are best
@dexterd5397
@dexterd5397 3 жыл бұрын
You are doing great work. Can you pls take combination sum problem from leetcode as well.
@respicio2990
@respicio2990 2 жыл бұрын
Jab jab input khali ho raha hai ..tab tab hame output mil raha hai , But base condition runs only once isn't it ? I am confused asf.
@user-em5hy9so6c
@user-em5hy9so6c 2 ай бұрын
What is the time complexity of above solution?
@manjeetsingh6028
@manjeetsingh6028 5 ай бұрын
Solution of subsets problem in javascript:- function subsets(input,output){ if(input.length
@ashaysant7844
@ashaysant7844 3 жыл бұрын
Can we remove the last index instead of the first one ? if we remove last index then the time taken to shift the array is 0 essentially because we are just stripping of the last value.
@ashaysant7844
@ashaysant7844 3 жыл бұрын
Note - when we remove the first element from linked list time taken is O(1). But for Array implementations the time taken would be to shift the entire array :)
@PIYUSH-lz1zq
@PIYUSH-lz1zq 2 жыл бұрын
is this applicable for numbers ???
@005ei60
@005ei60 3 жыл бұрын
Bhai array pe DP kaise lagaye,uspe bhi vedio banao..Thanks in Advance.
@b82tushar22
@b82tushar22 3 жыл бұрын
Extremely thanks
@shubhampokhriyal8491
@shubhampokhriyal8491 4 жыл бұрын
Bhaiya subset wala selection problem nhi hga kyuki hum select krte h please reply..
@bhavyagupta4319
@bhavyagupta4319 2 жыл бұрын
Sir the time complexity of this code will be 2^n??
@AK-yb4ml
@AK-yb4ml 4 жыл бұрын
Hi your patreon page is not supporting any debit card or PayPal and I have numerous times .plz use join of KZfaq instead to share your notes. THANKS BTW loving your videos.
@abhinavgupta8098
@abhinavgupta8098 4 жыл бұрын
bhai bhut pyaara
@tejaswigutta9017
@tejaswigutta9017 4 жыл бұрын
Bro,please please make a series on sliding window technique problems @Aditya Verma
@aksingh3470
@aksingh3470 4 жыл бұрын
use pointer.
@paritoshdadhich2954
@paritoshdadhich2954 3 жыл бұрын
Thanks for this video
@messi_codes
@messi_codes 3 жыл бұрын
i have done it using only IBH method . So my question is why do we should learn this method ?
@TheAdityaVerma
@TheAdityaVerma 3 жыл бұрын
Those names are just something I have given, behind the scenes everything works in the same way, IBH is nothing but a decision tree. (usually where we have one choice) IBH or IP-OP method both have decision tree as their backbone :D
@messi_codes
@messi_codes 3 жыл бұрын
@@TheAdityaVerma Thanks for explanation and reply Bhaiyaa.
@minhazulkabir5236
@minhazulkabir5236 2 жыл бұрын
@@messi_codes can you please share your code?(IBH method)
나랑 아빠가 아이스크림 먹을 때
00:15
진영민yeongmin
Рет қаралды 6 МЛН
wow so cute 🥰
00:20
dednahype
Рет қаралды 31 МЛН
Just Give me my Money!
00:18
GL Show Russian
Рет қаралды 651 М.
Can This Bubble Save My Life? 😱
00:55
Topper Guild
Рет қаралды 87 МЛН
나랑 아빠가 아이스크림 먹을 때
00:15
진영민yeongmin
Рет қаралды 6 МЛН