Recursion Google, Amazon Questions: Dice Throw & Letter Combinations of a Phone Number
In this video we cover some important questions on #recursion being asked in companies like Google and Amazon. Not only that, we also look at how to approach such problems, the thought process and come up with a solution.
LeetCode problems:
- Number of Dice Rolls With Target Sum
- Letter Combinations of a Phone Number
Take part in the learning in public initiative! Share your learnings on LinkedIn and Twitter with #DSAwithKunal & don't forget to tag us!
👉 Resources
- Join Replit: join.replit.com/kunal-kushwaha
- Complete Java DSA playlist: • Java + DSA + Interview...
- Code, Assignments, & Notes: github.com/kunal-kushwaha/DSA...
➡️ Connect with me: kunalkushwaha.com
=========================================
Timestamps:
00:00 Introduction
01:38 Q1 : Letter Combinations of a Phone Number
16:41 Code for Q1
20:41 Returning Q1 output as an ArrayList
24:58 Returning the count
27:09 Q2 : Number of Dice Rolls with Target Sum
32:40 Code for Q2
34:25 Returning Q2 output as an ArrayList
36:18 Dice with custom number of faces
37:50 Outro
#placement #dsa #interviews
Пікірлер: 218
Literally nobody has ever taught the way to abstract our thought process by applying Unprocessed & Processed approach for solving subset questions Thanks a million Kunal 🙏🙏🙏 Shoutout to DSA course with Kunal
@KunalKushwaha
2 жыл бұрын
Glad you liked it
Requires modification in the calculation of mapping phone-pad numbers to characters. As per Leetcode, 7 and 9 has 4 chars, so the value of i in the for-loop changes. public static List solve(String ans, String ip) { if(ip.isEmpty()) { ArrayList list = new ArrayList(); list.add(ans); return list; } int digit = ip.charAt(0) - '0'; int i=(digit-2)*3; if(digit > 7) { i+=1; } int len = i+3; if(digit == 7 || digit == 9) { len+=1; } ArrayList list = new ArrayList(); for(; i
@siddhantmeshram4092
2 жыл бұрын
Cannot thank you enough
@JOBFERNANDEZBCD
Жыл бұрын
thank you so much. helped me a lot
@akhilpathak1348
Жыл бұрын
Just add one edge case for digits.length()==0 , like this if(digits.length()==0){ ArrayList str = new ArrayList(); return str; } ** this edge case will be added in the main method** I was stuck because of this so thought of adding here for future reference XD
@anirudhchakravarty6373
Жыл бұрын
Thankyou so much pal!!
@prasaddd77
11 ай бұрын
From where does the final for loop start? You have just given a semi-colon there
Tears in my eyes man, literally solved without help. Thank You 3000 Kunal🙏🙏🙏
You're my only hope Kunal please continue this playlist list. Waiting for more on hash maps, trees, dynamic programming etc 🙏🙏
@amansayer4943
Жыл бұрын
deepak did you complete all the vedio lectures
@deepakjanardhanan7394
Жыл бұрын
@@amansayer4943 Yes
@atharvasarode8057
5 ай бұрын
did you got placed now??
@reverbmusic8444
3 ай бұрын
@@atharvasarode8057 No reply tells the answer 🤡🤡
@atharvasarode8057
3 ай бұрын
@@reverbmusic8444 🤣😅 real
I love how i am consistently improving for my upcoming interview! I am very lucky to find this channel.
Kunal, I owe you a debt of gratitude. Before your guidance, I never thought I could solve a recursive problem on my own. Your method of teaching us how to approach and find solutions was exceptional. Thank you for empowering me with the skills and confidence to tackle these challenges.
I was very frustrated with recursion and had given up on coding. Your recursion series has given me exemplary clarity, rekindled my hope and brought me back to coding again. Thank you so much!
when you have said what to do at 32:00, literally your intuition made me think how to do. thank you kunal kushwaha
Wow! I am following your recursion playlist and till now, I am able to solve these two problems on my on without looking your solution at first. Never though this gonna happen so fast!
Kunal your DSA videos are remarkable! Thank you for this.
This way of solving questions using up and p is lit 🔥💯, Thanks Man! Great Work 🙌🏻
I Cant explain in words , Hatts off to you Kunal !!, Thanks a lot for making this course available for us.
wondering!!!!!!! how easily you are able to explain a pattern or question soo nicely....thanks brother
I used to memorize solution before now I'm learning to build solution . Thanks kunal
It took me three hours but I was able to solve them by myself...best lecture on DSA recursion
One day I'll learn DSA just bcz of you kunal
Your Explanation is Amazing kunal bhai.. I completed My Civil Engeenering.. Now I am learning coding easily by you😍
Best Content I ever Seen . this is we needed . we need an approach to solve any question than solving questions : ) . Great Job . Appreciate 🔥
I usually don't comment on any KZread video but i had to appreciate you after watching this class. great job sir🙏
guys lets complete the recursive tree of dice problem .thank you kunal you left that tree at the half . i did it and it solved my lot of doubts .
The way you make all these so-called complex problems simple is just amazing ❣
Thankyou so much Kunal for this amazing series... ❤️
please make more videos I'm waiting just to learn from you , your teaching skill is amazing bro i have not found any other youtuber explaining technique like this , they all just jump to solution.but you show us how to think how to solve problems not directly jump to solution . very very thanks to you 🙏
Nice! I have seen lot of recursion tutorial but all are confusing. I feel this is the best one i find
Even a paid courses wont cover this detail.. Really liked the pattern you have taught.. Yay! I got the intuition to solve recursion problems.. Thanks Kunal.. Waiting for more videos on trees and graphs
Solving the question by understanding the pattern makes it easy to solve...Good thought process and recursion is being made easy with kunal...thanks Kunal 🙂
Thanks a lot ,I eagerly wait to see your tutorials .Great job ..
I am able to solve this combination question bt myself which i was believing i will never be able to solve by myself i just can't express my happiness thanks kunal
Hey Kunal, U are rockstar man. Literally i became fan of you. i subscribed and liked your videos. from today onwards i just like to follow you. You are so great.... God bless you.
Kunal another amazing video! I was able to modify the code for the phone question and get a accepted submission on leetcode as well! Keep up the great work!
Thank you so much Kunal .just following your course
Thanks for teaching not just recursion but also the thought process to aproach and solving the problem
his teaches shows that we are learning from PRO DSA .
everything cool but in original leetcode theres no every letter start from *3 bcs 7 is "pqrs", and 9 is "wxyz". I did the simillar job like you but with using additional list in constructor.Thanks for good videos!
kunal recursively telling us to go to previous videos is
Thank you so much for teaching me this pattern! I am so grateful for this channel :)
I got confidence after watching and practicing recursion series. Thanks @Kunal
One of the great mentor I have seen Please start a bootcamp of python after java . ❤️
These patterns are helping me a lot...Thank you so much for such an amazing lecture
Thanks Man! You deserves this comments and appreciation:)
Thank you so much Kunal ✨. Your videos are invaluable!
I'm solving some challenging problems, which I though I will never be able to, Thank you.
Best recursion course on youtube.
Wow! You explain so well!!! Gratitude
You are the greatest, Kunal!
wait, if (i
can anyone help me find BST link from Kunal's playlist?
I was able to solve this problem even without watching the solution. All the previous recursion videos taught me how to do this.Thanks a ton!
@KunalKushwaha
2 жыл бұрын
Excellent!
@yogeshsikanderpuriya7417
2 жыл бұрын
bro can u pls share the assignment solution(letter combination)...it will be a great help
@yashthakur6081
9 ай бұрын
can you share the solution?
@blurryface160
9 ай бұрын
@@yashthakur6081 public static char[] map(char ch){ HashMap map = new HashMap(); map.put('2',new char[]{'a','b','c'}); map.put('3',new char[]{'d','e','f'}); map.put('4',new char[]{'g','h','i'}); map.put('5',new char[]{'j','k','l'}); map.put('6',new char[]{'m','n','o'}); map.put('7',new char[]{'p','q','r','s'}); map.put('8',new char[]{'t','u','v'}); map.put('9',new char[]{'w','x','y','z'}); return map.get(ch); } public static List letterCombinations(String up,String p) { if(up.isEmpty()){ List temp = new ArrayList(); temp.add(p); return temp; } char []arr = map(up.charAt(0)); List ans = new ArrayList(); //You can use normal for loop instead of for each for (char c : arr) { List ansFromBelowCalls = letterCombinations(up.substring(1), p + c); ans.addAll(ansFromBelowCalls); } return ans; }
it finally just clicked for me thank you kunal
Damn the previous videos literally made it easier to understand these questions ⚡
Thanks for all videos kunal sir
Thank you for this Kunal!!
Lets dig in!
in LEETCODE 1st question topic is showing backtracking . But you have done it with recursion ..so is your solution good for an interview?..also what's it time complexity
You are really a great teacher!
Could you why we need i
This is an amazing tutorial, but no way from the simple subset problems you solve this dice and letters problem 😂😂😂 but am glad I've watched this cause this solution opened the road to many more problems.. p/up is just an amazing concept
have a doubt that instead of count function, can't we just return the size of the ans arrayList?
This question isn't talking about the keys being pressed multiple times. It is talking about T9, where you press the keys, once, and it forms a word that is possible from a preloaded dictionary.
At 33:35 , For coding in C++, Must use dice(p + to_string(i), target-1) to string will help you to convert int to char
@umangsrivastava6639
2 жыл бұрын
thanks bro actually i was stuck, can you also help me with previous recursion codes in c++. please
@rohitchilhorkar8114
2 жыл бұрын
@@umangsrivastava6639 I will help you..
@umangsrivastava6639
2 жыл бұрын
@@rohitchilhorkar8114 please do bro
@rohitchilhorkar8114
2 жыл бұрын
@@umangsrivastava6639 How can I contact you? Can you provide your email?
@yogeshyts
Жыл бұрын
integer + 'a' will also work
It's just perfect bro
Really awesome Recursion series, explained concepts in easy to follow steps 👍
@KunalKushwaha
10 ай бұрын
Glad you think so!
In the dice problem, why there is a condition i
26:20 why is not count value updated to 0 in each function call as count = 0 in the recursive function
Literally crazyy stufff🤯
thank you man, for all the quality content. Thank you for this video. Please start your patreon or something, I want to donate you for the good cause.
i am actually trying to solve these questions in c++ and not being able to solve it. syntax problem. if anyone can help please.
In Q.2 29:45 How you think that we should take 4 in unprocess and not the some data(given data i.e. [1,2,3,4,5,6]) ?
Can anyone tell the exact code for Letter Combination on Leetcode?
bro please help me with solution for phone pad with the same approach
Hi Kunal,When can we have trees and graphs??
yo pls complete the series bro,dont wanna learn trees n graphs from anyone else
37:00 Is the face needed because anyways we are going to run the loop till target only
Here is a recipe for these combinatorial algorithms: 1/ recursion with two main arguments results(starts off empty) and choices 2/ in each level of the recursion call the choices argument is decremented 3/when the choices length or value becomes 0, the value for the result argument is a valid result ( add it to the global results or return it) 4/the problem specific algorithm wil be on how to populate the result argument and decrement the choices argument for each recursive call, and the number of calls for each level can be either fixed or variable
Awesome explanation
when wil be the dynamic programming is going to start kunal bhai?
Sir, do u also share the solution of assignment questions??
Techstartup be like :- ab humare course kaise bikenge 😂😂😂
what's the time complexity of second question??
Before this course, I thought python is more beginner friendly. Anyone can teach solving a problem but it requires skills to teach how to approach a problem!
@SudhanshuKumar-xy6xv
Жыл бұрын
where is he using python bro
@ashwathks784
Жыл бұрын
@@SudhanshuKumar-xy6xv lol wrong course
@hardikthakre
Жыл бұрын
@@SudhanshuKumar-xy6xv 🤣
only due to you I was able to solve dice question on my own.Thank you bro!
@KunalKushwaha
2 жыл бұрын
Happy to help
@anmolhira8652
2 жыл бұрын
@@KunalKushwaha Brother when will you complete the playlist ?
@yashthakur6081
9 ай бұрын
can you share the solution?
Good Day! Greetings 🙏👍
I am still unable to think these complex things. Pls guide
Great content
Thanks 👍
thanks for the video
precious 🙏
When will you release the DP Series?
13:36. 3 3 ja 🤣🤣🤣and thanks kunal for all this
You're a legend.
video is really good Just a heads up In the actual question, there are no alphabets for 1 and also for 7 and 9, there are 4 letters instead of 3, make sure you modify the code accordingly
Best!!!
... also waiting for 100K ❤️
Can i also solve this using a dictionary ?
great video "value will go from 3 till " 19.04 😂 but anyways very helpful video thanks a lot
But I have a doubt, why are we considering the variable for face we can directly run the loop from 1 to target.
@zafeerrangoonwala4741
Жыл бұрын
target gets updated at every recursion call
sir aap jaise padhate hai, usse mai aap ka fan ho gaya hu and usse badh ke mai dsa ka ........ 1 more video to complete the recurssion playlist.... mai 2 weeks se yahi padh raha hu.... kisi ko kheta hu ki abhi bhi recurssion hi padh raha hu......sabb haste hai......ki time waste karr raha hi......itna time kon padhata hai recurssion.....but i know ......whats going on....... thanks
@KunalKushwaha
2 жыл бұрын
sabko ignore maaro
@haha44261
2 жыл бұрын
@@KunalKushwaha 🙂🙂yupp
Video 34 Completed!
Спасибо!
still watching consistently 😀😀😀😀😀