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

  • @kanyapandey
    @kanyapandey2 жыл бұрын

    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

    @KunalKushwaha

    2 жыл бұрын

    Glad you liked it

  • @deepaksolanki1972
    @deepaksolanki19722 жыл бұрын

    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

    @siddhantmeshram4092

    2 жыл бұрын

    Cannot thank you enough

  • @JOBFERNANDEZBCD

    @JOBFERNANDEZBCD

    Жыл бұрын

    thank you so much. helped me a lot

  • @akhilpathak1348

    @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

    @anirudhchakravarty6373

    Жыл бұрын

    Thankyou so much pal!!

  • @prasaddd77

    @prasaddd77

    11 ай бұрын

    From where does the final for loop start? You have just given a semi-colon there

  • @ichigolameeeee2423
    @ichigolameeeee2423 Жыл бұрын

    Tears in my eyes man, literally solved without help. Thank You 3000 Kunal🙏🙏🙏

  • @deepakjanardhanan7394
    @deepakjanardhanan7394 Жыл бұрын

    You're my only hope Kunal please continue this playlist list. Waiting for more on hash maps, trees, dynamic programming etc 🙏🙏

  • @amansayer4943

    @amansayer4943

    Жыл бұрын

    deepak did you complete all the vedio lectures

  • @deepakjanardhanan7394

    @deepakjanardhanan7394

    Жыл бұрын

    @@amansayer4943 Yes

  • @atharvasarode8057

    @atharvasarode8057

    5 ай бұрын

    did you got placed now??

  • @reverbmusic8444

    @reverbmusic8444

    3 ай бұрын

    @@atharvasarode8057 No reply tells the answer 🤡🤡

  • @atharvasarode8057

    @atharvasarode8057

    3 ай бұрын

    @@reverbmusic8444 🤣😅 real

  • @determinator4491
    @determinator44912 жыл бұрын

    I love how i am consistently improving for my upcoming interview! I am very lucky to find this channel.

  • @user-kt2uu9qt8l
    @user-kt2uu9qt8l Жыл бұрын

    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.

  • @Tomharry910
    @Tomharry910 Жыл бұрын

    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!

  • @santhosh7042
    @santhosh70422 жыл бұрын

    when you have said what to do at 32:00, literally your intuition made me think how to do. thank you kunal kushwaha

  • @kartikmehta17
    @kartikmehta17 Жыл бұрын

    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!

  • @advaitbajaj4241
    @advaitbajaj42412 жыл бұрын

    Kunal your DSA videos are remarkable! Thank you for this.

  • @pratikmundokar2381
    @pratikmundokar23812 жыл бұрын

    This way of solving questions using up and p is lit 🔥💯, Thanks Man! Great Work 🙌🏻

  • @dipakingle6629
    @dipakingle66292 жыл бұрын

    I Cant explain in words , Hatts off to you Kunal !!, Thanks a lot for making this course available for us.

  • @SaiSumanthKovuru
    @SaiSumanthKovuru9 ай бұрын

    wondering!!!!!!! how easily you are able to explain a pattern or question soo nicely....thanks brother

  • @nitin9042
    @nitin90422 жыл бұрын

    I used to memorize solution before now I'm learning to build solution . Thanks kunal

  • @anitasahoo8418
    @anitasahoo841810 ай бұрын

    It took me three hours but I was able to solve them by myself...best lecture on DSA recursion

  • @San-ix7ki
    @San-ix7ki2 жыл бұрын

    One day I'll learn DSA just bcz of you kunal

  • @JP-bj1fx
    @JP-bj1fx2 жыл бұрын

    Your Explanation is Amazing kunal bhai.. I completed My Civil Engeenering.. Now I am learning coding easily by you😍

  • @brainglitch
    @brainglitch2 жыл бұрын

    Best Content I ever Seen . this is we needed . we need an approach to solve any question than solving questions : ) . Great Job . Appreciate 🔥

  • @sakshibhagat4806
    @sakshibhagat4806 Жыл бұрын

    I usually don't comment on any KZread video but i had to appreciate you after watching this class. great job sir🙏

  • @amansayer4943
    @amansayer4943 Жыл бұрын

    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 .

  • @shreyasharma1625
    @shreyasharma16252 жыл бұрын

    The way you make all these so-called complex problems simple is just amazing ❣

  • @anchit1237
    @anchit12372 жыл бұрын

    Thankyou so much Kunal for this amazing series... ❤️

  • @aakashyadav9117
    @aakashyadav9117 Жыл бұрын

    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 🙏

  • @abhishekkumarsingh7352
    @abhishekkumarsingh73527 ай бұрын

    Nice! I have seen lot of recursion tutorial but all are confusing. I feel this is the best one i find

  • @sudhabeliver
    @sudhabeliver2 жыл бұрын

    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

  • @jamespeterson7824
    @jamespeterson78242 жыл бұрын

    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 🙂

  • @mohammedf7147
    @mohammedf71472 жыл бұрын

    Thanks a lot ,I eagerly wait to see your tutorials .Great job ..

  • @tanubaghel5204
    @tanubaghel5204 Жыл бұрын

    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

  • @edukondalugumma3753
    @edukondalugumma37532 жыл бұрын

    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.

  • @navnav1819
    @navnav18194 ай бұрын

    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!

  • @jonukutirahul3326
    @jonukutirahul33262 жыл бұрын

    Thank you so much Kunal .just following your course

  • @advrakshachaudhari3699
    @advrakshachaudhari36999 ай бұрын

    Thanks for teaching not just recursion but also the thought process to aproach and solving the problem

  • @codingonly6680
    @codingonly66802 жыл бұрын

    his teaches shows that we are learning from PRO DSA .

  • @_MrThief_
    @_MrThief_10 ай бұрын

    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!

  • @sofiyarao815
    @sofiyarao8152 жыл бұрын

    kunal recursively telling us to go to previous videos is

  • @amruthaa5876
    @amruthaa58762 жыл бұрын

    Thank you so much for teaching me this pattern! I am so grateful for this channel :)

  • @shubhamyeole2881
    @shubhamyeole2881 Жыл бұрын

    I got confidence after watching and practicing recursion series. Thanks @Kunal

  • @harshavardhangulla4058
    @harshavardhangulla40582 жыл бұрын

    One of the great mentor I have seen Please start a bootcamp of python after java . ❤️

  • @manasagorle
    @manasagorle3 ай бұрын

    These patterns are helping me a lot...Thank you so much for such an amazing lecture

  • @pratikmundokar2381
    @pratikmundokar23812 жыл бұрын

    Thanks Man! You deserves this comments and appreciation:)

  • @tolulopemalomo8922
    @tolulopemalomo8922 Жыл бұрын

    Thank you so much Kunal ✨. Your videos are invaluable!

  • @chinmaiveera2105
    @chinmaiveera21052 жыл бұрын

    I'm solving some challenging problems, which I though I will never be able to, Thank you.

  • @kirtishghosh8950
    @kirtishghosh89502 жыл бұрын

    Best recursion course on youtube.

  • @mrrishiraj88
    @mrrishiraj882 жыл бұрын

    Wow! You explain so well!!! Gratitude

  • @gamaleri7
    @gamaleri78 ай бұрын

    You are the greatest, Kunal!

  • @pranaychoubey829
    @pranaychoubey8292 жыл бұрын

    wait, if (i

  • @_ia_wotblitz1400
    @_ia_wotblitz14002 жыл бұрын

    can anyone help me find BST link from Kunal's playlist?

  • @Gnaneshh
    @Gnaneshh2 жыл бұрын

    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

    @KunalKushwaha

    2 жыл бұрын

    Excellent!

  • @yogeshsikanderpuriya7417

    @yogeshsikanderpuriya7417

    2 жыл бұрын

    bro can u pls share the assignment solution(letter combination)...it will be a great help

  • @yashthakur6081

    @yashthakur6081

    9 ай бұрын

    can you share the solution?

  • @blurryface160

    @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; }

  • @felixboachieyiadom4457
    @felixboachieyiadom4457 Жыл бұрын

    it finally just clicked for me thank you kunal

  • @sujalsamai6459
    @sujalsamai64592 жыл бұрын

    Damn the previous videos literally made it easier to understand these questions ⚡

  • @ibrahim-lf5he
    @ibrahim-lf5he2 жыл бұрын

    Thanks for all videos kunal sir

  • @annabatman9010
    @annabatman9010 Жыл бұрын

    Thank you for this Kunal!!

  • @tusharpapnai2907
    @tusharpapnai29072 жыл бұрын

    Lets dig in!

  • @DevanshuAugusty
    @DevanshuAugusty Жыл бұрын

    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

  • @rohitchilhorkar8114
    @rohitchilhorkar81142 жыл бұрын

    You are really a great teacher!

  • @nishanthsunkara1160
    @nishanthsunkara11606 ай бұрын

    Could you why we need i

  • @code2287
    @code2287 Жыл бұрын

    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

  • @vinuthnareddy3601
    @vinuthnareddy36019 ай бұрын

    have a doubt that instead of count function, can't we just return the size of the ans arrayList?

  • @pradiptasarma4867
    @pradiptasarma48672 жыл бұрын

    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.

  • @rohitchilhorkar8114
    @rohitchilhorkar81142 жыл бұрын

    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

    @umangsrivastava6639

    2 жыл бұрын

    thanks bro actually i was stuck, can you also help me with previous recursion codes in c++. please

  • @rohitchilhorkar8114

    @rohitchilhorkar8114

    2 жыл бұрын

    @@umangsrivastava6639 I will help you..

  • @umangsrivastava6639

    @umangsrivastava6639

    2 жыл бұрын

    @@rohitchilhorkar8114 please do bro

  • @rohitchilhorkar8114

    @rohitchilhorkar8114

    2 жыл бұрын

    @@umangsrivastava6639 How can I contact you? Can you provide your email?

  • @yogeshyts

    @yogeshyts

    Жыл бұрын

    integer + 'a' will also work

  • @chinmaychaudhari4143
    @chinmaychaudhari41432 жыл бұрын

    It's just perfect bro

  • @apoorvabhadauria3024
    @apoorvabhadauria302410 ай бұрын

    Really awesome Recursion series, explained concepts in easy to follow steps 👍

  • @KunalKushwaha

    @KunalKushwaha

    10 ай бұрын

    Glad you think so!

  • @jcchandru96
    @jcchandru968 ай бұрын

    In the dice problem, why there is a condition i

  • @absingh773
    @absingh773Ай бұрын

    26:20 why is not count value updated to 0 in each function call as count = 0 in the recursive function

  • @prajwalruke
    @prajwalruke9 ай бұрын

    Literally crazyy stufff🤯

  • @vasujhawar.6987
    @vasujhawar.69872 жыл бұрын

    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.

  • @umangsrivastava6639
    @umangsrivastava66392 жыл бұрын

    i am actually trying to solve these questions in c++ and not being able to solve it. syntax problem. if anyone can help please.

  • @DnyaneshPise
    @DnyaneshPise2 ай бұрын

    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]) ?

  • @anmolverma075
    @anmolverma075 Жыл бұрын

    Can anyone tell the exact code for Letter Combination on Leetcode?

  • @mageshwaran3321
    @mageshwaran3321 Жыл бұрын

    bro please help me with solution for phone pad with the same approach

  • @sathyammedia6553
    @sathyammedia65532 жыл бұрын

    Hi Kunal,When can we have trees and graphs??

  • @Rajdweep
    @Rajdweep2 жыл бұрын

    yo pls complete the series bro,dont wanna learn trees n graphs from anyone else

  • @gowtham9153
    @gowtham91537 ай бұрын

    37:00 Is the face needed because anyways we are going to run the loop till target only

  • @aminefourati1258
    @aminefourati125810 ай бұрын

    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

  • @sourabhkothari7014
    @sourabhkothari70142 жыл бұрын

    Awesome explanation

  • @FaizShaikh-dt8wp
    @FaizShaikh-dt8wp Жыл бұрын

    when wil be the dynamic programming is going to start kunal bhai?

  • @yashverma685
    @yashverma6855 ай бұрын

    Sir, do u also share the solution of assignment questions??

  • @suyashkumar8840
    @suyashkumar88402 жыл бұрын

    Techstartup be like :- ab humare course kaise bikenge 😂😂😂

  • @anujmaurya6145
    @anujmaurya61452 жыл бұрын

    what's the time complexity of second question??

  • @aditya__exe
    @aditya__exe2 жыл бұрын

    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

    @SudhanshuKumar-xy6xv

    Жыл бұрын

    where is he using python bro

  • @ashwathks784

    @ashwathks784

    Жыл бұрын

    @@SudhanshuKumar-xy6xv lol wrong course

  • @hardikthakre

    @hardikthakre

    Жыл бұрын

    @@SudhanshuKumar-xy6xv 🤣

  • @Gurjeetsingh-ks5dv
    @Gurjeetsingh-ks5dv2 жыл бұрын

    only due to you I was able to solve dice question on my own.Thank you bro!

  • @KunalKushwaha

    @KunalKushwaha

    2 жыл бұрын

    Happy to help

  • @anmolhira8652

    @anmolhira8652

    2 жыл бұрын

    @@KunalKushwaha Brother when will you complete the playlist ?

  • @yashthakur6081

    @yashthakur6081

    9 ай бұрын

    can you share the solution?

  • @mrrishiraj88
    @mrrishiraj882 жыл бұрын

    Good Day! Greetings 🙏👍

  • @codingwithaddy155
    @codingwithaddy155 Жыл бұрын

    I am still unable to think these complex things. Pls guide

  • @akshaykumar-wd8jc
    @akshaykumar-wd8jc2 жыл бұрын

    Great content

  • @harshjaiswal1634
    @harshjaiswal16342 жыл бұрын

    Thanks 👍

  • @maddymadhu
    @maddymadhu10 ай бұрын

    thanks for the video

  • @dineshmadduru7043
    @dineshmadduru7043Ай бұрын

    precious 🙏

  • @ishansharma8625
    @ishansharma86255 күн бұрын

    When will you release the DP Series?

  • @01utpalraj95
    @01utpalraj952 жыл бұрын

    13:36. 3 3 ja 🤣🤣🤣and thanks kunal for all this

  • @SagarBisen-kt8ex
    @SagarBisen-kt8ex4 ай бұрын

    You're a legend.

  • @nalamanuraag802
    @nalamanuraag8024 ай бұрын

    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

  • @samruddhighodake223
    @samruddhighodake2232 жыл бұрын

    Best!!!

  • @ffbad3129
    @ffbad31292 жыл бұрын

    ... also waiting for 100K ❤️

  • @meaningless9094
    @meaningless90945 ай бұрын

    Can i also solve this using a dictionary ?

  • @ssu1782
    @ssu1782 Жыл бұрын

    great video "value will go from 3 till " 19.04 😂 but anyways very helpful video thanks a lot

  • @soumyadeeppaul2175
    @soumyadeeppaul21752 жыл бұрын

    But I have a doubt, why are we considering the variable for face we can directly run the loop from 1 to target.

  • @zafeerrangoonwala4741

    @zafeerrangoonwala4741

    Жыл бұрын

    target gets updated at every recursion call

  • @haha44261
    @haha442612 жыл бұрын

    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

    @KunalKushwaha

    2 жыл бұрын

    sabko ignore maaro

  • @haha44261

    @haha44261

    2 жыл бұрын

    @@KunalKushwaha 🙂🙂yupp

  • @itshari5489
    @itshari548911 ай бұрын

    Video 34 Completed!

  • @ElizabethOlamisan-nh3xr
    @ElizabethOlamisan-nh3xr Жыл бұрын

    Спасибо!

  • @rudram4534
    @rudram45342 жыл бұрын

    still watching consistently 😀😀😀😀😀