Summary: 1. Today's question is the culmination of Combination Sum-I and Combination Sum-II 2. Instead of having a given vector nums or arr, we are asked to consider numbers from 1 to 9(both inclusive) 3. We can also visualise them to be inside an array but actually we don't to create it and use extra space. 4. Now we need to pass in the void help() the following parameters: 1) i for the element and n for the target sum 2) sumTillNow to calculate the sum we have accumulated till now 3) k for the number of elements we require in our subset 4) vector subset and vector ans 5. Now we will have the base conditions: a) if(k==0) It means we have calculated the number of elements required. Thus check whether sumTillNow== n. If so include it in the subset else simply return b) if(sumTillNow > n) We have a sum which is more than target, and as we don't have negative numbers we cannot form n so we simply return. c) if(i==10) We can have elements till 9 only. So we return 6. Now we pick the i-th element into our subset , increment sumTillNow by i and ask Recursion to do the calculation for i +1 elements. 7. When we return, we backtrack the changes, decrement sumTillNow by i and pop_back() the inserted element. 8. We now ignore the i-th element, so we simply call for i+1 and ask Recursion to do the remaining task. Time Complexity: O(2^N) [ In worst case, we need to include all the elements till 9 to have n] Space Complexity: O(N) [ Height of Recursive Tree]
@emtiazahmed53332 жыл бұрын
I just love your summary & i included this into my note🥰🥰
@utkarshchauhan58272 жыл бұрын
Guys I have doubt that Jaise ki bhaiya ne jab sumtillnow==n wali condition lgayi,to unhone sumtillnow>n waali top wali condition comment kardi.inhone jo reason diya wo satisfiied nhi lga ,kyunki yeh condition to important lagi agar k=7 ho and N=11 Ho aur is case me agar yeh condition na ho to hamara control aur aage badhta jayega jaah iski zaroorat bhi nhi hogi aur complexity bharayega,to please koi mera doubt clarify kardo
@daniyalhussain5231 Жыл бұрын
This playlist is so so underrated. Fraz you are an absolute legend.
@aasifali91392 жыл бұрын
bhaiya, i dont think you realize how much you are helping me and others by making this gem series. Absolutely Love it. Thx a lot for the effort you are putting in your videos for us. THANKS again..............
@nithins38952 жыл бұрын
I have done this differently And now im seeing your code is more optimized... Thanks for the HW prblms so that we can try and then we can see your way of doing and learning the things clearly Thanks for the video Bhai
@rounaq_khandelwal Жыл бұрын
Loving these series!!
@maazulhaque72932 жыл бұрын
Episode - 14 Done Thanks Fraz bhaiyya
@alien65629 Жыл бұрын
solved it by myself with the help of previous combination codes. THANKS FRAZ Bhaiya 😄
@davv-r5b9 ай бұрын
Now In this Type Combination Sum 3 , main change from other types is The Given K value : 1. we have to return vector with k length of elements that sum up to N value: 2. Now main approach for this is to Remember That we have to stop When Our K count expires. 3. And then check whether our sum is N equivalent or Not. 4. Applying Simple Pick And Not-Pick approach . 5. And as we have given that range is 1 to 9 , then there is no element occuring duplicately. 6. And when we will add some element to our Temp Vector , then our Count or K should be change. 7. But not At the time of Not-Picking the element , because the no of elements remains same . /// This is the Summary Of this Lecture /// For more clarity Refer To CombinationSum1 and CombinationSum2 Problems First
@jayantmishra68972 жыл бұрын
rarely i subscribe any channel but whatever content that you are providing makes me to subscribe this channel .
@DPCODE722 жыл бұрын
For the first on Utube who is bringing a quality of good understanding video over the Recursion if he I will keep teaching us like this insane way then it is gonna be 🔥!!
@mohdumar69902 жыл бұрын
Now, I understand combination concept using recursion 👍
@SahilVanarse-n4x7 ай бұрын
Because of him I am able to solve the next questions ...logic building 💪💪
@nitigyajoshi465811 ай бұрын
sumTillNow can be incremented in function call as well. This was really intuitive. Thanks for the great explaination.
@ranitbandyopadhyay2 жыл бұрын
Was not available yesterday. As more and more constraints are introduced, the problems are getting more and more interesting and your explanation also. Good work.
@jayantmishra68972 жыл бұрын
and i have one suggestion for you is that is please display the question for a moment so we get little more idea about that.i know before you start explaining you explain about the question very well but this will be additional point for us.
@webtechnology64392 жыл бұрын
Sir, I am self-building logic without a video watch. Verry Exited 💥💥💥
@ankushladani4962 жыл бұрын
Now Understanding Recursion in a good way. Thank you Bhaiya....
@Abhishek-fo3fc2 жыл бұрын
Done Understood ❤✅
@surgeonofdeath81992 жыл бұрын
lol i used the trick u used in first question named combination and it worked then checked out ur solution it is same really glad that i was able to do a medium level question myself this time
@priyanshusingh89712 жыл бұрын
Completed lecture and Commeting for better reach
@aashuvyas7862 жыл бұрын
very Great Series! i was able to solve this problem wihtout even seeing this video just with help of you previous videos
@AtomicAkshay2 жыл бұрын
Notes: The problem requires understanding of both subset and combination problems, once we have that it is somewhat straightforward to solve, important thing was to identify the base conditions for the recursion. Time Complexity: O(n ^ 9) Represents upper bound, although runtime complexity might be lesser due to presence of k Space Complexity: O(n) Excluding size of result array
@avadhutlohar51812 жыл бұрын
#EP_14 Completed Consistency OP 🔥🔥🔥 Congrats for 10K❤ Rise and Shine 🌟
@utkarshchauhan58272 жыл бұрын
Guys I have doubt that Jaise ki bhaiya ne jab sumtillnow==n wali condition lgayi,to unhone sumtillnow>n waali top wali condition comment kardi.inhone jo reason diya wo satisfiied nhi lga ,kyunki yeh condition to important lagi agar k=7 ho and N=11 Ho aur is case me agar yeh condition na ho to hamara control aur aage badhta jayega jaah iski zaroorat bhi nhi hogi aur complexity bharayega,to please koi mera doubt clarify kardo
@ratnasanjay2 жыл бұрын
Thankyou bhaiya for this session
@sarojgupta55622 жыл бұрын
Fraz bhaiya i am following ur dsa course and its really helpful...thank u for all the content and consistency..thank u bhaiya
@sanjeevkumar-pk1ko2 жыл бұрын
If u know completely comb. sum 1, 2 then this problem just take 2 mins : just add some new base conditions void fun(int i,int k,int tar,int sum,vector & subset,vector & ans){ if(i>10){return;} if(tar==sum && subset.size()==k){ ans.push_back(subset); return; } if(subset.size()>k)return; //taking i in ans subset.push_back(i); sum+=i; fun(i+1,k,tar,sum,subset,ans); //backtrack subset.pop_back(); sum-=i; fun(i+1,k,tar,sum,subset,ans); } vector combinationSum3(int k, int n) { vector ans; vector subset; fun(1,k,n,0,subset,ans); if(ans.size()==0){} return ans; }
@it_08amanagarwal352 жыл бұрын
Excellent lecture bro sorry today I am late to comment as I watch the video but intuition behind question is helping me to solve more no of questions❤❤❤❤❤❤❤❤❤❤❤❤❤❤❤❤❤❤
@mdsufyankhan10292 жыл бұрын
L14 done ✅✅ Consistency++ 🔥🔥
@yashpadiyar49522 жыл бұрын
Thankuuuuu ,luvv u bhaiya🤗🤗♥️
@Lucifer-xt7un2 жыл бұрын
Congratulations for 10k subscribers 🤩🥳😍
@anuraggulati21672 жыл бұрын
lecture 14 done waiting for the next lecture👌👌 feeling confident now in recursion 😎😎🙌💚💚
@utkarshchauhan58272 жыл бұрын
Guys I have doubt that Jaise ki bhaiya ne jab sumtillnow==n wali condition lgayi,to unhone sumtillnow>n waali top wali condition comment kardi.inhone jo reason diya wo satisfiied nhi lga ,kyunki yeh condition to important lagi agar k=7 ho and N=11 Ho aur is case me agar yeh condition na ho to hamara control aur aage badhta jayega jaah iski zaroorat bhi nhi hogi aur complexity bharayega,to please koi mera doubt clarify kardo
@sadikahmed30452 жыл бұрын
Congratulations 👏🎉🎉 for 10k
@chiragkarnwal67402 жыл бұрын
Thanks for the lecture sir💝
@Gauravkumar-kc6xh2 жыл бұрын
Great
@cinemaclockwork2152 жыл бұрын
It's really helpful
@jayantmittal66652 жыл бұрын
Awesome Content!
@mohitroshan38562 жыл бұрын
Ep 14 done ✌️
@sagarpokhriyal69262 жыл бұрын
Lecture 14 Completed ☑ Congratulations bhaiya for 10k. Many more to come💫 #dsabyfaraz☀
@divyanshsagar2 жыл бұрын
Episode 14 done! 🔥🔥
@singla__sisters29282 жыл бұрын
Nice Explanation, Please discuss contest questions as wellll
@satyammishra63562 жыл бұрын
Ep-14 Done ✅
@ShubhamKumar-lf7ed2 жыл бұрын
u are great sir
@anishsingh47502 жыл бұрын
Present bhaiya!
@klvp_techie2 жыл бұрын
Logic: For every element of an array we have two choices, either to consider it or ignore it if we consider the element update the sum and add it to subset and ask recursion to do the rest and undo all changes you did earlier (# Backtracking) if we ignore it , ask the recursion to do remaining task Base Condition: if sum > target return if length of subset == required check for the sum == target save in ans and return Code: def helper(i,a,k,b,sumTillNow,subset,ans): if sumTillNow > b: return if k == 0: if sumTillNow == b: ans.append(subset[:]) return # if k < 0: # return # if sumTillNow == b: # if k == 0: # ans.append(subset[:]) # return if i > a: return #consider the i sumTillNow += i subset.append(i) helper(i+1,a,k-1,b,sumTillNow,subset,ans) sumTillNow -= i #not considering i subset.pop() helper(i+1,a,k,b,sumTillNow,subset,ans) a = 9 # upper bound of input k = 2 # required length of subset b = 6 # target sum ans = [] subset = [] sumTillNow = 0 helper(1,a,k,b,sumTillNow,subset,ans) print(ans)
@utkarshchauhan58272 жыл бұрын
Guys I have doubt that Jaise ki bhaiya ne jab sumtillnow==n wali condition lgayi,to unhone sumtillnow>n waali top wali condition comment kardi.inhone jo reason diya wo satisfiied nhi lga ,kyunki yeh condition to important lagi agar k=7 ho and N=11 Ho aur is case me agar yeh condition na ho to hamara control aur aage badhta jayega jaah iski zaroorat bhi nhi hogi aur complexity bharayega,to please koi mera doubt clarify kardo
@uavishal7772 жыл бұрын
Best Explanation 🔥🔥
@LearnYardYT2 жыл бұрын
Glad you liked it
@riyagoel42822 жыл бұрын
best content
@vishalgowrav2 жыл бұрын
Episode 14 completed! Combination Sum III Here, The problem is the combination of previous two problem but here we want to return the subsets in which the sum shd be equal to n and count of subset cannot exceed k so in order to achieve it We are incrementing sum and Decrementing k (same as previous problems) and in the base condition we have to check for both sum and k using nested if. Time complexity:- O(2 pow n) Space complexity:- O(n)
@utkarshchauhan58272 жыл бұрын
Guys I have doubt that Jaise ki bhaiya ne jab sumtillnow==n wali condition lgayi,to unhone sumtillnow>n waali top wali condition comment kardi.inhone jo reason diya wo satisfiied nhi lga ,kyunki yeh condition to important lagi agar k=7 ho and N=11 Ho aur is case me agar yeh condition na ho to hamara control aur aage badhta jayega jaah iski zaroorat bhi nhi hogi aur complexity bharayega,to please koi mera doubt clarify kardo
@isikamaiti91162 жыл бұрын
14 done ✅
@someshkharat58492 жыл бұрын
hii fraz..appreciate everything u r doing for us..just want to ask u if u could please explain the backtracking lil bit more..
@LearnYardYT2 жыл бұрын
Yes in coming episodes i will
@utkarshchauhan58272 жыл бұрын
Guys I have doubt that Jaise ki bhaiya ne jab sumtillnow==n wali condition lgayi,to unhone sumtillnow>n waali top wali condition comment kardi.inhone jo reason diya wo satisfiied nhi lga ,kyunki yeh condition to important lagi agar k=7 ho and N=11 Ho aur is case me agar yeh condition na ho to hamara control aur aage badhta jayega jaah iski zaroorat bhi nhi hogi aur complexity bharayega,to please koi mera doubt clarify kardo
@manikgoel99532 жыл бұрын
Thanks you bhaiya
@NikhilTiwari-to7sv Жыл бұрын
sir please make a playlist on stacks and queues
@mohdsaadalikhan72092 жыл бұрын
if(k>9-i+1){// required k numbers > remaining numbers return; } this base condition can also be added to further optimise
@santoshkumarpaul53042 жыл бұрын
Bhaiya plz solve leetcode example
@aveermukherjee64192 жыл бұрын
Sir will you provide video explanation for the test problems. I was not able to do two problems. It would be very helpful. And sir you said that you will be starting a basic course consisting of array algos binary search etc. It will be very helpful if you start it early.
@kamranwarsi12b222 жыл бұрын
In the question it is mentioned we cannot use same numbers between 1 to 9 , so can we use that while condition while(i+1==i && i
@ashokbhardwaj6812 жыл бұрын
Bhaiya beginner series kab se start hogi pls 🙏 reply
@anirudrabrahma_09712 жыл бұрын
What about exam questions solution discussion...??btw enjoyed another nice video ❤️
@ecs185_shaileshbharti32 жыл бұрын
Reach++: ✌️💥
@yashbahuguna81352 жыл бұрын
done for day 14
@shalimar_mehra2 жыл бұрын
Present ! ✔🙌 ok ! It Was Pretty Good but I'm Trying ! I'm facing so many problems ! Can you sir please make an video on [ How to Build logic in program so it was help me for solving my questions ] Thanks a lot sir for this lovely video ! I'm trying my best ! 🙌
@mohdkhaleeq74682 жыл бұрын
Fraz bhai teach Greedy Algorithms topic also
@ksankethkumar72232 жыл бұрын
What is the time complexity of this problem? is it one among these two O(k*9^k) or O(n^2)? Or what is the correct time complexity?
@DTMASUYASHMISHRA2 жыл бұрын
Sirr Maine pehle ekk vector of int bana liya usme 1to 9 element daal diye arr usi m pick and ignore it khela ar sum karta gya pehle question jaise arr sari base condition laga dii arr shi hoo gya
@ammysaini102 жыл бұрын
👌❤️
@vicky-xf5nx2 жыл бұрын
❤️
@jayanthipenugonda72742 жыл бұрын
why can't we use if(sumTillNow>n || k
@utpaltripathi95772 жыл бұрын
Another base condition for optimization can be- if( ( n - sum ) < ( k * ( k + 1 ) ) /2 ) return; wait! I am explaining also... (n-sum) : It is remaining sum that we have to include. k : number of elements needed to include their value in sum k * ( k + 1 ) ) /2 : sum of first 'k' elements from 1+2+...+k. (minimum possible sum of unique k elements) So think mathematically, if required sum of k unique elements is less than minimum possible sum of k unique elements, then we can't get our result. Correct me pls I am wrong...
@Lucifer-xt7un2 жыл бұрын
Consistency ++
@Anonymous-om5ql2 жыл бұрын
Bhaiya, where is the HW problem link?
@utkarshchauhan58272 жыл бұрын
Guys I have doubt that Jaise ki bhaiya ne jab sumtillnow==n wali condition lgayi,to unhone sumtillnow>n waali top wali condition comment kardi.inhone jo reason diya wo satisfiied nhi lga ,kyunki yeh condition to important lagi agar k=7 ho and N=11 Ho aur is case me agar yeh condition na ho to hamara control aur aage badhta jayega jaah iski zaroorat bhi nhi hogi aur complexity bharayega,to please koi mera doubt clarify kardo
@naveen_kotha2 жыл бұрын
Can I get the Questions which were asked in Recursion Contest 1 as I am unable to attempt it
@yeswanthh50682 жыл бұрын
☺️💚💚🙏🙏🙏
@pn55632 жыл бұрын
Hello I'm mech 17 pass out with 57 pointer in garduation after work 2.6 yr looking for switch in IT industry because in 12th I'm Computer science student then because people suggest us in our town so we select mechanical who go in future to switch so after 1 yr of work in mechanical field i looking class but i don't know how to apply or go I don't have Idea then lockdown happens I'm looking offline class now i join Java course .....also while listening on KZbin DSA is important so I'm here after watching ur video please please guide me how to apply for job after completing course of 6 months please 🙏
@harshbardhansingh41412 жыл бұрын
Bro how to get an internship for a 2nd year student I mean where and how to apply because we don't have any specific experience in the role and the Company how to select us....bcoz sab koi bol dete hai ki ye karlo woh karlo interest pai koi v skill pey sikh kar ke internship kar lo but koi ye nahi batata ki kaise apply kare...itni bheed main hum kaise uss company Mai as a fresher internship paye... Can you make a complete separate video in this topic...🥺🙏
@emtiazahmed53332 жыл бұрын
Bro i wait for 2h 🙃... Aj kitney lare kyu ho giya? Everything is fine??
@LearnYardYT2 жыл бұрын
When I rendered the video it didn't come out fine. Then re-rendered, it took time
@RajputAnkit112 жыл бұрын
sad today i am not able to solve and watch this video will do tomorrow sad
@BurhanAijaz2 жыл бұрын
Day 14 bhaiya aaj itna late kyu, sab khairiyat
@ayan842402 жыл бұрын
First
@comic_forever2 жыл бұрын
aaj no homework problem bhaiya?
@vivekpaanchal2 жыл бұрын
New series kab aari hai ?? google join kar ke channel bhul gye 🥲🥲
@LearnYardYT2 жыл бұрын
Nahi bro jaldi ayegi Was working on leadcoding.in/ Do check out
@vivekpaanchal2 жыл бұрын
@@LearnYardYT kal video aate hi dekh liya tha 😌❤️ , so bhi Jaya karao raat ko bhaiya 🥲🥺
@dashundev15862 жыл бұрын
Uploaded late so watching late
@akashyadagouda8968 ай бұрын
missing Striver here
@dashundev15862 жыл бұрын
And there’s no notification
@RajputAnkit112 жыл бұрын
i worte my own code just forget to stop when i becomes 10
@akashnigam53212 жыл бұрын
Bhai agar tu nhi hoga to pata nhi recursion kaise samajh pate 🥺