Thank you very much for awesome explaination . Most of the comment section of his all videos are usually requesting for different topics or correcting or asking for some sort of help. We all are so selfish , the guy is teaching (BEST in the world) and that to for free of cost. Despite getting a high salary job , he is still spending his value able time for us . I think we should accept it and appreciate his work and not force him to make video based on our requirements
Initially add 1 in output string n pass no of zero as 0 n one as 1 n as n-1....then if o>z then we can add one or zero otherwise only one... Hope this helps
Trust me, this guy's a living legend. Just a month ago I couldn't even write a single line of code for a basic recursion problem and eventually ended up doing this question just after hearing the problem statement. 🎩📴
I was able to solve recursion questions but after this, I m able to solve problems in much lesser time. These videos gave me immense clarity on how to approach a question.
Before Watching this series I was not able to approach basic problems of recursion....but now due to Your help i am easily able to do medium level questions.Thanku sir for this❤
before starting this series I was having problem while solving problems of recursion and now I am solving the question before watching the explanation video..Thanks, Aditya Verma
Sir Awesome videos.This might be No.1 channel to prepare and clear the concepts... It gives too much bust for interview preparation..! Waiting for Backtracking problems..
I, just like others in comments, wasn't able to write basic recursive code. However, after watching this playlist, I coded this ques just after hearing the problem statement. Thanks Aditya!
You are great brother. I am one of those CS student who always preferred maintaining a safe distance from recursion. As a result I was getting feverish feeling whenever I was facing problems that need DP to solve. I came across your DP playlist first and after watching a few videos I felt if anyone can teach me Recursion, it is Aditya Verma only. Now I am solving problem before looking into your solutions. You are just a gift of GOD. Stay healthy and happy brother. Keep teaching us with your amazing teaching skills.
I was fearing the recursion. Whenever i saw recursion i tried to do it with loops but never got the answer in required time complexity. At the starting of the series he said that after completing the entire playlist you will become Jedi. And yes after completing i can say i have become Jedi in Recursion. Thanks a lot for helping me out. You are doing a great job here.... ❤️💯🔥
Solved this question in 5 min, even before watching it, just on the basis of the knowledge gained from the previous videos in the playlist. Great work man.. hats off to you. 👏👏👏
about to finish this playlist just one more question left, normally i dont even have to watch your complete video thanks to your explanation. thanks a lot hope u return to youtube
Thank you so much sir. With your help I am so much confident with recursion and backtracking. I was so depressed and having second option other than learning DSA. But finally I am able to solve medium range problems gradually and got my confidence back. I will be always grateful to you. Again, thanks a lot.
Just click on video saw first 10 sec and think let me understand myselft about ip-op and ps click on the link and understand the problem then first try to make the recursive tree ofcourse first time I failed to do . then again think about the problem and retry to build the recursive tree and this time somehow I made it and see what I code it as you taugh once you made a recursive writing code will be cake work . so I just run code again test case and it passes😄 that is the power of your teaching . Thankyou aditya Bhaiya for your efforts ! You are The BEST 🙃.
i was literally able to solve this question on my own in the first go...all thanks to your efforts bro..( this playlist is must for everyone who thinks recursion sucks.)
Thanks a lot bro for your effort. It's been a great help for me. Just a request can you please make videos on Greedy,backtracking and divide & conqueror
I really liked your way of teaching and keep on building problems based on previous thinking. it helps a lot to grasp concepts. just one suggestion. try to provide a few examples of a problem that requires for loop along with recursion. like print all permutation of array elements.
Thank you so much Bhaiya , because after following this playlist completely , I was able to solve this question just by reading the problem statement. Hats Off to you Bhaiya ..
Finished without seeing the solution !!! public void generate(String op, int n0, int n1, int N, ArrayList list){ if(n0 + n1 == N){ list.add(op); return; } String op1 = op + "1"; generate(op1, n0, n1-1, N , list); if(n0 > n1){ String op2 = op + "0"; generate(op2,n0-1,n1,N,list); } }
Thank you so much for the recursion playlist FINALLY I UNDERSTOOD THE CONCEPT Also please could you also make videos on backtrackingggg Thanks dude!!!!
I tried this, is it fine or should I change my approaches? function printBit(n,i,ans,p,q){ if(p>q){ return } if(i===n){ console.log(ans) return } printBit(n,i+1,ans+'0',p+1,q) printBit(n,i+1,ans+'1',p,q+1) } printBit(4,0,'',0,0)
Another base condition could be if n0+n1 == n We won't have to reduce n Here's the python code """ For an input N, print the total number of n bit binary numbers for which, the number of 1's in all the prefixes is greater than or equal to number of 0's Example 1: Input: n = 2 Output: "11, 10" Explanation: Valid numbers are those where each prefix has more 1s than 0s: 11: all its prefixes (1 and 11) have more 1s than 0s. 10: all its prefixes (1 and 10) have more 1s than 0s. So, the output is "11, 10". Example 2: Input: n = 3 Output: "111, 110, 101" Explanation: Valid numbers are those where each prefix has more 1s than 0s. 111: all its prefixes (1, 11, and 111) have more 1s than 0s. 110: all its prefixes (1, 11, and 110) have more 1s than 0s. 101: all its prefixes (1, 10, and 101) have more 1s than 0s. So, the output is "111, 110, 101". """ from typing import List def getAllNBitBinaryNumbers(allNBitBinaryNumbers:List[str], n0:int, n1:int, op:str, N:int): if n0 + n1 == N: allNBitBinaryNumbers.append(op) return op1 = op + "1" getAllNBitBinaryNumbers(allNBitBinaryNumbers, n0, n1+1, op1, N) if n1 > n0: op2 = op + "0" getAllNBitBinaryNumbers(allNBitBinaryNumbers, n0+1, n1, op2, N) if __name__ == "__main__": n = int(input("Number of bits needed ins string ? ")) allNBitBinaryNumbers = [] n0 = 0 n1 = 0 op = "" getAllNBitBinaryNumbers(allNBitBinaryNumbers, n0, n1, op, n) print(allNBitBinaryNumbers) Please let me know if there are any suggestions on improvement :) Thanks for the teachings Aditya
Sir I think you missed questions on Longest Increasing Subsequence and it's variations in DP playlist. Those problems are tricky sometimes. Please discuss those as well
javascript code function main (p){ let n = p let zero = 0 let one = 0 let op = "" solve(n,one,zero,op) } function solve(n,one,zero,op){ if(n == 0){ console.log(op) return } if(one == zero){ let op1 = op + "1" solve(n - 1,one + 1,zero,op1) }else if(one > zero){ let op1 = op + "1" let op2 = op + "0" solve(n - 1,one + 1,zero,op1) solve(n - 1,one,zero + 1,op2) } } main(5)
Your work is really great . No one has ever taught recursion in the same manner you are teaching .You are teaching us how to use a tool so that it can be used whenever necessary .I can say now that I really know recursion , I've solved this problem without looking into your solution . Really grateful for this hard work really appreciate your work bro . Thanks a lot .
python code : def gen(op,one,zero,n): if n==0: print(op) return if op=='': op = op + "1" gen(op,one+1,zero,n-1) elif one > zero: op2 = op +"1" gen(op2,one+1,zero,n-1) op1 = op + "0" gen(op1,one,zero+1,n-1) else: op = op + "1" gen(op,one-1,zero,n-1) op = '' n = 3 one = zero = 0 gen(op,one,zero,n)
Thanks brother, making videos is easy, but dealing with these issues (hissing sound/low audio) is really a headache 😓😓Now I know how hard these other quality youtubers work.
cpp code //Print N-bit binary numbers having more 1’s than 0’s for any prefix #include using namespace std; void solve(string output,int one ,int zero,int n){ if(n==0){ cout
Thanks for the videos. Learning a lot from them. Had one question, I tried it on my own before starting the video. Had one doubt. Do you think 1 will always be prioritized when #0 == #1. This is how I wrote in Swift. func solve(_ out: String, _ zero: Int, _ one: Int, _ n: Int) { if n == 0 { print(out) return } if zero == one { // When zero and 1 both are same then we need to give preference to 1 let op1 = "\(out)1" solve(op1, zero, one+1, n-1) } if zero < one { let op1 = "\(out)0" let op2 = "\(out)1" solve(op1, zero+1, one, n-1) solve(op2, zero, one+1, n-1) } return } let n = 5 solve("1", 0, 1, n-1) Result: 10101 10110 10111 11001 11010 11011 11100 11101 11110 11111 Please let me know your thoughts!
Thank You So much bro for this playlist it is really improving my problem solving skills. Because of You, I am able to solve last parenthesis and this problem and other many problems without seeing Logic . Thank You So Much For great video series......
void solve(int n, string res, vector &vec, int ones=0, int zeros=0){ if(n == 0){ if(ones>=zeros){ vec.push_back(res); } return; } solve(n-1, res+"1", vec, ones+1, zeros); if(!res.empty()) solve(n-1, res+"0", vec, ones, zeros+1); } vector NBitBinary(int N) { // Your code goes here string str; vector st; solve(N, str, st); return st; } I was trying this for the above question but its giving output limit exceeded. Can someone suggest where I am going wrong
Thanks Bro for doing this from your heart with one goal to help others. You are doing without any expectation from others. Follow this attitude/simplicity using pen and paper, definitely you will get what you want in life. The good thing is that you are not wasting time in basics(definition etc) the way or approach you are building to solve problem is awesome. Below list is considered as best material for Data Structure and Algorithm there is no comparison of your videos to this. Even your videos are very help full for experience ones also they have to also face first coding round. 1. Cracking the Coding Interview, 6th Edition :Gayle Laakmann McDowell 2. Introduction to Algorithms Third Edition : Thomas H. Cormen Charles E. Leiserson Ronald L. Rivest Clifford Stein 3. RU-vid video : Abdul Bari If possible add English subtitles. After that you can see the difference in your video will reach to world wide. Subscribed your channel.
JAVASCRIPT SOLUTION function subset(n,one,zero,arr){ if(n==0){ console.log(arr); return; } subset(n-1,one+1,zero,arr+'1'); if(one>zero){ var arr2=arr; var n2=n; subset(n2-1,one,zero+1,arr2+'0'); }; return; } var no=3; var o=0; var z=0; var ar=''; subset(no,o,z,ar);