Тёмный

Print Subsets | Print PowerSets | Print all Subsequences 

Aditya Verma
Подписаться 249 тыс.
Просмотров 190 тыс.
50% 1

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.

Опубликовано:

 

15 сен 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 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 7 месяцев назад
​@@vivekgoswami1474backtracking kaha se padha bhai?
@vivekgoswami1474
@vivekgoswami1474 7 месяцев назад
@@SohelDarwajkar backtracking ko bhi video daal d inhone check
@SohelDarwajkar
@SohelDarwajkar 7 месяцев назад
@@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 😅..
@mehulgarg7253
@mehulgarg7253 2 месяца назад
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....
@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
@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 ???
@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 ???
@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 🙌🙌😁
@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 !!
@vivekchaudhary1768
@vivekchaudhary1768 4 года назад
Bhai adiya verma, bhagwan tujhe lambi umer de. first time aise vedio mili hai jisme itna sahi btaya hai
@rishikumar-rk7tk
@rishikumar-rk7tk 4 года назад
Watched all videos of every playlist Till now and waiting for more.. Thankyou for making such an important channel
@chesteriglesias1025
@chesteriglesias1025 4 года назад
Bro please make BACKTRACKING videos.Your explanations are unanimously best on RU-vid.Thanks a lot man❤️
@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.
@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..😊😊
@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
@susrandomguy
@susrandomguy 2 года назад
Broooo the way you explain the solution is something else🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥
@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 ??
@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 4 года назад
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
@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.
@anandpandey918
@anandpandey918 2 месяца назад
/* * 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
@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
@sagardas4569
@sagardas4569 4 года назад
Sachme vaiya apke vdo ki starting k music sei ek motivation milti he❤️
@NewBIE-xz5jm
@NewBIE-xz5jm 7 месяцев назад
Did myself in 15 min! thanks bro!
@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.
@ShubhamKumar-xs7ul
@ShubhamKumar-xs7ul 4 года назад
bhaiya please add questions on binary trees which is totally dependent on recursion. Thanks
@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 ???
@farzanaiqbal3768
@farzanaiqbal3768 4 года назад
Please do a video on: Print all permutations of a string!
@shivamagrawal3542
@shivamagrawal3542 3 года назад
use backtracking
@abhinandanb3591
@abhinandanb3591 3 года назад
@@shivamagrawal3542 how
@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 3 года назад
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.
@akashjain4281
@akashjain4281 4 года назад
Keep the good work going ! Amazing videos. 👍😃
@yugamverma8403
@yugamverma8403 8 месяцев назад
//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 ); }
@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
@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
@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; }
@madhurimasen7086
@madhurimasen7086 3 года назад
this is the best explanation I have ever seen!
@siddhantrai7613
@siddhantrai7613 4 года назад
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 2 месяца назад
@@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.
@abhishekdwivedi-ll5ky
@abhishekdwivedi-ll5ky 2 года назад
Best teacher for coding
@gaurav2010kumar
@gaurav2010kumar 2 года назад
recursion jaadu hai bhai .. Thanks a lot brother! you are the best! Please add graphs playlist as well
@ishwaripednekar5164
@ishwaripednekar5164 2 года назад
Best Print all subset solution till now ❤️
@PIYUSH-lz1zq
@PIYUSH-lz1zq 2 года назад
is this applicable for numbers ???
@avishjain4281
@avishjain4281 2 года назад
instead of erase function we can just pass ip.substr(1); it returns the string remaining after the first element
@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
@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!
@souravmajumder6598
@souravmajumder6598 4 года назад
Glad to see your lecture brother👌 Take love from Bangladesh ❤🇧🇩
@vibhorsoni8517
@vibhorsoni8517 3 года назад
bhai feel dila de recursion ke , thanks a lot bhai
@nikitachaudhari2800
@nikitachaudhari2800 3 года назад
Most liked youtuber of mine❤️
@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)
@thetravelers937
@thetravelers937 2 года назад
time complexity is o(2^n) .am i right ??
@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.
@nero-kun-here
@nero-kun-here 4 года назад
Thank you so much for this great playlist.
@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
@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 :)
@_ApoorvaShinde
@_ApoorvaShinde 3 года назад
Thanks for making recursion so easy!
@princegarg1086
@princegarg1086 4 года назад
bhaiya please make video on Asymptotic notations and time complexity and space complexity
@bommakantibeeraiah1486
@bommakantibeeraiah1486 5 месяцев назад
is can we able to do with array because we are not able to small the input with array?
@SatyamKumar-bw4vi
@SatyamKumar-bw4vi 2 года назад
Hare Krishna!🙏🙏 Great Work
@sayasark
@sayasark 2 года назад
Wonderfully explained!! thank you.
@manjeetsingh6028
@manjeetsingh6028 6 месяцев назад
Solution of subsets problem in javascript:- function subsets(input,output){ if(input.length
@Prateek_Mantry
@Prateek_Mantry 5 месяцев назад
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
@KshitijKumarOfficial
@KshitijKumarOfficial 7 месяцев назад
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
@priyanshkumar17
@priyanshkumar17 8 месяцев назад
Thanks ! Awesome Explanation...
@Khabibullah
@Khabibullah 4 года назад
Bhai aapka Flipkart and Nutanix interview experience share kab karoge.
@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
@sankalparora9374
@sankalparora9374 Год назад
Way better Sound quality in this one.
@satyamgupta5423
@satyamgupta5423 Год назад
#include using namespace std; void subsets(string input,string output){ if(input.size()==0){ cout
@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); } }
@rishabsharma5307
@rishabsharma5307 4 года назад
zindagi mein pheli bar smjh mein aaya hai
@pranshukashyap6848
@pranshukashyap6848 4 года назад
Please DP ki playlist pure Complete kardo.. LIS, Kadanes's wagera bache hain.. Plz next usse complete kardo..
@mayank8
@mayank8 3 года назад
thanks a lot for explaining so beautifully
@PIYUSH-lz1zq
@PIYUSH-lz1zq 2 года назад
is this applicable for numbers ???
@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
@dexterd5397
@dexterd5397 3 года назад
You are doing great work. Can you pls take combination sum problem from leetcode as well.
@endlessloopsoftwares4724
@endlessloopsoftwares4724 3 года назад
Bhaut mast smjhaya bhai!!
@user-em5hy9so6c
@user-em5hy9so6c 3 месяца назад
What is the time complexity of above solution?
@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
@Sauravk2107
@Sauravk2107 Год назад
If we call recursive function first on op1 and then op2 , it gives error . Why??
@tejaswigutta9017
@tejaswigutta9017 4 года назад
Bro,please please make a series on sliding window technique problems @Aditya Verma
@aksingh3470
@aksingh3470 4 года назад
use pointer.
@pradnyeshmali4207
@pradnyeshmali4207 2 года назад
how would you deal with negative number? it's taking -sign as a character...
@shashankmishra6705
@shashankmishra6705 Месяц назад
how to memoize this. I am getting TLE on large test cases.
@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[:]
@vikashkumarchaurasia1299
@vikashkumarchaurasia1299 4 года назад
awesome explaination bro. thanks
@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.
@AyushKumar-po8no
@AyushKumar-po8no 22 дня назад
It does not work for array like ip: [1,2] and op: [[], [1], [2], [1,2]]
@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.
@005ei60
@005ei60 3 года назад
Bhai array pe DP kaise lagaye,uspe bhi vedio banao..Thanks in Advance.
@durgaprasadkakarla5311
@durgaprasadkakarla5311 Год назад
please put atleast subtitles sir, it will be helpful for us
@neharikakhera6411
@neharikakhera6411 4 года назад
Thanks .. great explanation
@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 RU-vid instead to share your notes. THANKS BTW loving your videos.
@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
@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?
@kushagrasaxena8831
@kushagrasaxena8831 4 года назад
Recursion OP!
@deeproy7292
@deeproy7292 4 года назад
bhaiya you are best
@b82tushar22
@b82tushar22 3 года назад
Extremely thanks
@anjukumari-ib2md
@anjukumari-ib2md 4 года назад
I tried this approach by taking String input = "abc" this is working fine.. but i tried same in int array [1,2,3] then it is not giving correct output ( tried in java ).. can anyone help me please .. ? this is my code public static void solve(ArrayList ip,ArrayList op ){ if(ip.size()==0){ System.out.println(op); return; } ArrayList op1 = op; ArrayList op2 = op; op2.add(ip.get(0)); ip.remove(0); solve(ip,op1); solve(ip,op2); }
@rachanaraut5718
@rachanaraut5718 4 года назад
Hey did you find the solution and what different approach we have to take for numbers?
@abulkasimlaskar
@abulkasimlaskar 3 года назад
You are manipulating in the original input and output , instead of creating a new instance for every new input and output. Please check this code: -------------------------------------------------------------------------------------------------------------------------- void subset(List input,List output) { if(input.size() == 0) { System.out.println(output); return; } List op1 = new ArrayList(output); List op2 = new ArrayList(output); op2.add(input.get(0)); input.remove(0); subset(new ArrayList(input), op1); subset(new ArrayList(input), op2); } --------------------------------------------------------------------------------------------------------------------------------
@kush3764
@kush3764 Год назад
@@abulkasimlaskar Thank you bhai
@DaudZaidi
@DaudZaidi 3 года назад
Time complexity will be: (2^(N+1)) - 1
@harshalgarg1149
@harshalgarg1149 3 года назад
Can you please explain this?
@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 ???
@RajveerSingh-yf1os
@RajveerSingh-yf1os 6 месяцев назад
ye wala code run to hora hai but test cases pass nhi krr rhaa koi bhi
@ishanikasingh9321
@ishanikasingh9321 3 года назад
void solve(string s, string op, vector &v){ if(s.length()==0){ v.push_back(op); return; } string op1=op; string op2=op; op2.push_back(s[0]); s.erase(s.begin()+0); solve(s,op1,v); solve(s,op2,v); return; } vector powerSet(string s) { //Your code here string op=""; vector v; solve(s,op,v); return v; }
@PIYUSH-lz1zq
@PIYUSH-lz1zq 2 года назад
is this applicable for numbers ???
@bhavyagupta4319
@bhavyagupta4319 2 года назад
Sir the time complexity of this code will be 2^n??
@avinashkumarrao9728
@avinashkumarrao9728 Год назад
why we are not using & in input and output
@paritoshdadhich2954
@paritoshdadhich2954 3 года назад
Thanks for this video
Далее
Print unique subsets And Variations
24:48
Просмотров 106 тыс.
Reverse a Stack using Recursion
14:59
Просмотров 123 тыс.
L6. Recursion on Subsequences | Printing Subsequences
25:01
Tower of Hanoi | Recursion
24:01
Просмотров 168 тыс.
Print all SubSequences of an array Recursive Solution
11:23
Generate all Balanced Parentheses
34:03
Просмотров 146 тыс.