Recursion - Array Questions (Theory + Code + Tips)

Поділитися
Вставка
  • Опубліковано 20 гру 2024

КОМЕНТАРІ • 462

  • @KunalKushwaha
    @KunalKushwaha  4 місяці тому +3

    DSA + interview preparation playlist: ua-cam.com/play/PL9gnSGHSqcnr_DxHsP7AW9ftq0AtAyYqJ.html

  • @surajgupta3267
    @surajgupta3267 3 роки тому +415

    This man is providing quality content for free...far better than the paid ones ♥️

    • @teslatestingwala5019
      @teslatestingwala5019 3 роки тому +6

      He gets Powerfull blessings

    • @jayakumar9976
      @jayakumar9976 3 роки тому +7

      i can personal vouch for it!!..

    • @logeesh2009
      @logeesh2009 2 роки тому +2

      Agreed

    • @er.albertaddy2386
      @er.albertaddy2386 2 роки тому +7

      but many important topics mentioned in website are missing, say maps, trees etc. hes also not interested to share.

    • @devincodes5218
      @devincodes5218 Рік тому +1

      No lies... Plus making seemingly hard concepts easy to grasp.

  • @erharshphysics3835
    @erharshphysics3835 2 роки тому +64

    32:00 😁😁 "You've skipped the course I can't help you. Go watch the video properly" and then you says "ok, I'll repeat it."😂

    • @veeee5577
      @veeee5577 4 місяці тому +2

      he's the best teacher he just wants his students to not get confused

  • @vedantyt2451
    @vedantyt2451 3 роки тому +41

    Sometimes it's that aura of Kunal which makes us comfortable in getting the hard concepts easily.

  • @albin6126
    @albin6126 Рік тому +5

    your non formal and more friendly way of teaching feel very connected and its like you directly talking to a person

  • @budgetdapr
    @budgetdapr 3 роки тому +131

    Been going on and off studying CS because I was stuck on recursion. Used to stop studying in a matter of minutes since I couldn't understand anything related to it. Watched 3 videos of your RECURSION PLAYLIST and now recursion is a cakewalk to me. The best 3-4 hours I've ever invested, not even capping

    • @KunalKushwaha
      @KunalKushwaha  2 роки тому +26

      Glad I could help

    • @Kondlapudi
      @Kondlapudi 2 роки тому +4

      I agree!!

    • @panchanansahoo1463
      @panchanansahoo1463 2 роки тому +5

      Thanks kunal for all the videos .But please upload remaining videos after stack and queue as well

    • @meetabhashiniparida9417
      @meetabhashiniparida9417 2 роки тому +1

      @@KunalKushwaha in 1:03:42 why is it returning [3, 4] and not [4, 3]....since its returning from the stack's top, it should first add 4 into the list n then 3 right?

    • @ujjwalagnihotri5001
      @ujjwalagnihotri5001 Рік тому

      @@meetabhashiniparida9417 if you haven't still figured out yet, then because call for index =3 will happen first and it will get added in arraylist.

  • @vittalmaheshwari5348
    @vittalmaheshwari5348 3 роки тому +62

    Hey Kunal it has been a superb journey with you
    I got a job offer from Microsoft
    This is all because of your videos and your hardwork
    Thank a lot Kunal
    I will support you till my last breath

  • @subhankarkanrar9494
    @subhankarkanrar9494 10 місяців тому +11

    If anyone watches the first time, i will say , please see all the videos carefully previously and watch the full video. Don't skip anyone

    • @bruvhellnah
      @bruvhellnah 7 місяців тому +1

      bro did you understand recursion completely from his videos?

  • @ashaysaoji2273
    @ashaysaoji2273 8 місяців тому

    Excellent explanation for returning a list without passing an argument!
    Starting Timestamp: 49:47

  • @projecthope2836
    @projecthope2836 2 роки тому +12

    Thanks Kunal, you're really a rare gem, I have understood recursion by just watching your contents

  • @aashashanmugam
    @aashashanmugam 8 місяців тому +1

    This series is hands down THE best videos on Recursion!! Thanks so much Kunal!!

  • @rakeshbabu4790
    @rakeshbabu4790 3 роки тому +77

    Increase the frequency of dsa videos Kunal🙏🏻🙏🏻🥺🥺

  • @AftabAlam-gh1nh
    @AftabAlam-gh1nh 2 роки тому +2

    My code for question at 3:18
    public static boolean Check(int arr[]) {
    int index = 0;
    return helper(arr, index);
    }
    private static boolean helper(int arr[], int index) {
    if(index==arr.length-1) {
    return true;
    }
    else if(arr[index]>arr[index+1]) {
    return false;
    }
    return helper(arr, index+1);
    }

  • @Virtualexist
    @Virtualexist 6 місяців тому +3

    Mannnn, no matter how much striver, ye bhaia wo bhaia teach N queen or any difficult problem and boast about it.. this man teaches you what makes you solve these problems by self. It is not about solving one problem, it is about learning to solve many such problems.

    • @subhamsoni3853
      @subhamsoni3853 6 місяців тому +1

      striver's playlist is complete unlike his

    • @Virtualexist
      @Virtualexist 6 місяців тому

      @@subhamsoni3853 Ah I seee. I completed from Aditya Verma and i come back to this to clear basic doubts.

    • @AshirwadSarmah
      @AshirwadSarmah 4 місяці тому

      @@subhamsoni3853 is this playlist really not complete? what is he missing?

  • @spryzenplays2500
    @spryzenplays2500 4 місяці тому +3

    it's like i am sitting in front of Kunal and he can see my expressions & he is scolding me that why are you not getting these simple concepts😂

  • @kushalappabe1993
    @kushalappabe1993 Місяць тому

    The part where this video leads to explaination of passing arguments as parameters avoiding multiple object creation made me feel I have to genuienly thank you! Highest of respect and Highest of Regards for what you have done. Thank you!

  • @maheshgayakwad4227
    @maheshgayakwad4227 Рік тому

    bhaiya aapne bola tha ki recurssion me problem aayegi per mujhe to bahut easy lg raha hai ye....
    maybe all because u are such a good teacher .. thakyou

  • @memestok893
    @memestok893 2 роки тому +2

    44:38
    code in Python
    def LiS(arr,target,index,NewList=[]):
    if index==len(arr)-1:
    return NewList
    if arr[index]==target:
    NewList.append(index)
    return LiS(arr,target,index=index+1)
    print(LiS([4,2,3,4,4,4,5],4,0))

    • @ayushkumar2418
      @ayushkumar2418 2 роки тому +1

      Hey @Memestok, did you managed to write 1:03:10 code in python ?

  • @ashisbhowmik348
    @ashisbhowmik348 3 роки тому +9

    You deserve a Big shoutout ❤️❤️❤️ for providing this type of quality education ..💯💯💯

  • @gurjargaming863
    @gurjargaming863 Рік тому

    Bhaiya you are great aapki wajah se mera recursion itna best hoo gaya he ki me aab koisa bhi question bhot aaram se krr leta huu

  • @programmer9803
    @programmer9803 11 днів тому

    Best DSA Course on JAVA on Entire UA-cam💕

  • @vigneshvijayakumar-ty4ob
    @vigneshvijayakumar-ty4ob 5 місяців тому

    Hey Kunal, you are such an amazing tutor. You think about all the perspective of watcher, like where they will get doubt and you are explaining it repeatedly without hesitation. Thank you so much Kunal.

  • @rishabhrawat8197
    @rishabhrawat8197 2 роки тому +4

    you were right now i'm able to solve complex questions in my finger tips

  • @veeee5577
    @veeee5577 4 місяці тому

    thanks for taking so much time for making this course its worth thousands of dollars and yet you made it free may god bless you.

  • @akashnag6459
    @akashnag6459 Рік тому +1

    No one explained Recursion as easy as you. Thanks a lot. A lot of paid courses doesnt explain Rescursion as you did.

  • @yaswanthkosuru
    @yaswanthkosuru 2 роки тому +1

    these playlist of recursion
    deserve million of views

  • @abdullahalosaimi8506
    @abdullahalosaimi8506 2 роки тому

    Thank you for the amazing work you do. Another solution for question 5 is returning an empty list when the index is greater than or equal to array length instead of creating a new list in every call.
    def find_all_indcies(target, index):
    if index >= len(nums):
    return []
    results = find_all_indcies(target, index + 1)
    if nums[index] == target:
    results.append(index)
    return results

  • @YashwaniVerma-q5s
    @YashwaniVerma-q5s 10 місяців тому +2

    I can't thankyou enough for this amazing lecture. I understood the whole lecture.
    If you can make a lecture on DP it will be a big help.

  • @ridoychandradey8337
    @ridoychandradey8337 2 роки тому +1

    So many things I have learnt so far. This is the best recursion content among all videos in youtube. Thanks a lot KUNAL.

    • @JodFlashYT
      @JodFlashYT 2 роки тому

      Bro did you have handwritten notes of kunal it's giving me error in github 🥲 plz reply if you have

    • @ridoychandradey8337
      @ridoychandradey8337 Рік тому

      @@JodFlashYT I have few of these. But not all. When I was taking the notes my handwriting was very messy as well. If you want to know anything then you can tell me and I will give you the fb or linkedin profile link.

  • @ishanvyas2178
    @ishanvyas2178 5 місяців тому

    when you understand the thing he is explaining totally, It feels so so satisfying

  • @sauravagrawal5013
    @sauravagrawal5013 Рік тому +2

    Simpler code at 1:03:08 is -
    static ArrayList findAllIndexWithout(int[] arr, int start, int target){
    ArrayList arrlist = new ArrayList();
    if(start==arr.length){
    return arrlist;
    }
    // this will contain answer for that function call only.
    if(arr[start]==target){
    arrlist.add(start);
    }
    ArrayList ansFromBelowCalls = findAllIndexWithout(arr, start+1, target);
    // if current arrlist has no value then return the previous ArrayList returns.
    if (arrlist.size()==0){
    return ansFromBelowCalls;
    }
    // if current arrlist is not empty then add all the elements from previous arraylist returns to the current arrlist
    // and return the arrlist.
    else{
    for(Integer i: ansFromBelowCalls){
    arrlist.add(i);
    }
    return arrlist;
    }
    }

  • @entity2.089
    @entity2.089 Рік тому

    Guess what i checked every dsa course, really couldn't find anything better than this and anyone better than you kunal❤❤❤❤❤❤❤

  • @riyazahmadkhan9490
    @riyazahmadkhan9490 3 роки тому +15

    Understanding recursion helping me to understand other data structures in detail and fast too
    Thank you so much Kunal for providing quality content

  • @chinmayatewari7589
    @chinmayatewari7589 Рік тому +7

    The level of dedication and the quality of content💯.... TONS OF RESPECT AND SUPPORT ❤

  • @Helly_Patel
    @Helly_Patel 2 роки тому +19

    Thanks for teaching us like no one did till now!! One small request, please make lectures on dynamic programming as well!!

  • @webhelpbyvarghab
    @webhelpbyvarghab Рік тому +2

    *C++ Code for returning vector without passing answer vector to the recursive function*
    vectorsolve(int target, vectorarr, int index){
    vectorres;
    if(index==arr.size()) return res;
    if(target==arr[index])res.push_back(index);
    vectortemp = solve(target, arr, index+1);
    if(!res.empty()) temp.push_back(res[0]);
    return temp;
    }
    int main(){
    vectorans = solve(4, {3,6,8,9,4,2,4}, 0);
    for(int x:ans){
    cout

  • @dipeshjadhav1546
    @dipeshjadhav1546 2 роки тому +19

    Hats off to the efforts this guy has put in making these videos, Wish we had teachers like this in our collage. I wish you all the luck man and wish all your dreams come true.. Contributing to the better world. Thank you so much man

  • @sharansukesh5542
    @sharansukesh5542 3 роки тому +20

    Insane teaching man
    I was able to come up with my own solution in one line for linearsearch
    return index == arr.length ? false : arr[index] == target || linearSearch(arr, index + 1, target);

  • @samuelmanukonda286
    @samuelmanukonda286 2 роки тому +4

    One of the best courses I have come across so far. You are doing an incredible job.
    Just a suggestion.
    People who are having issues understanding the last return statement, try assigning a local variable to it and then return it, so you can see the stack getting cleared after each function call which makes it easier to understand.

  • @satnamsingh3801
    @satnamsingh3801 2 роки тому +2

    Your courses are the reason I bought UA-cam premium😊

  • @ujjwalkumar7267
    @ujjwalkumar7267 3 роки тому +1

    Hats off to his calmness, you are such a brilliant tutor, I am new to this channel, going to watch all the videos and learn different concepts..!!!

  • @sujithsaikalakonda4863
    @sujithsaikalakonda4863 2 роки тому +4

    Hey, Kunal. Great Explanation. Especially the way you explained 'Return the list without passing the argument' was awesome and clearly understood. Great Work

  • @shivakumarkonga1532
    @shivakumarkonga1532 10 місяців тому +1

    Classes are Extremely well......😍😍

  • @FaizanFurqanAhmad
    @FaizanFurqanAhmad 10 місяців тому +1

    Honestly :-> Your teaching way is fantastic and advance level.
    You are the real example of what's the knowledge we can get from youtube 💯 ❤
    Love uhhh bro ❤

  • @jknair0
    @jknair0 3 роки тому +2

    You are doing Gods work! So much knowlege with so much clarity for free. Thank you Kunal!

  • @jamespeterson7824
    @jamespeterson7824 2 роки тому +2

    Recursion has been explained very nicely ,simple and understandable manner... Good work 🙂

  • @pradeepella
    @pradeepella 2 роки тому +2

    Man the dedication ur putting teach all these and ur notes is very much helpfull and ur teaching this for free hatsoff for u, ur best than many other paid courses at present . God ur kunal

  • @thanushkrishna2041
    @thanushkrishna2041 2 роки тому

    One of the take aways is how to add a result of child recurrisve call to parent recurssive call and carry it forward adding again and again to a parent call !! New concept.. Liked your presentation, thank you !!

  • @ShivamPandey-jc8rh
    @ShivamPandey-jc8rh 2 роки тому

    never thought these concepts would be so easy to understand bhai agar yhi videos khi hindi me upload maar diye hote to ajj tabahi ho jati cse field me .

  • @charanteja4619
    @charanteja4619 Рік тому +1

    Bro simply increasing competition in the Industry!

  • @Tomharry910
    @Tomharry910 2 роки тому +1

    Best way to learn recursion anywhere. Thank you so much Kunal Sir 🙏

  • @vikaskumarnitrr
    @vikaskumarnitrr 3 роки тому +8

    By the time I had subscribed to your channel, I always wait for your next upload just a little request, just increase the speed of uploading videos.
    love you 3000 Kunal bhaiya

  • @manashbarman273
    @manashbarman273 2 роки тому +3

    Bro please add the tree and graph videos as well.. I am 4 yrs experience at a service based org. But I must say you content is top notch in terms of explanation. I became fan of yours

  • @aayushojha3088
    @aayushojha3088 3 роки тому +12

    Mann you teach so awesome!!!!!!!, i was able to do the subsequence question by passing arraylist in the argument by my own because i had watched you arraylist video and as you keep on telling make the tree so i did that and was able to solve it , so happy mann!!

  • @suryaganeshpindiprolu472
    @suryaganeshpindiprolu472 2 роки тому

    This man is making me fall in love with coding especially recursion

  • @imranjamshaid8708
    @imranjamshaid8708 Рік тому

    what a Quality Lectures.I never seen on UA-cam

  • @mayank3411
    @mayank3411 Рік тому +1

    A really nice work done by you brother...Really a best video of Recursion...

  • @PriyaSingh-zb5wn
    @PriyaSingh-zb5wn 8 місяців тому

    Thank you for another excellent lecture. It helped me in getting better at recursion .You really know what you are doing.

  • @poetryiscodingdecoding7965
    @poetryiscodingdecoding7965 2 роки тому

    One of the finest content of the globe today

  • @adilwahla544
    @adilwahla544 2 роки тому

    THANK YOU KUNAL for such an amazing content

  • @lucifer.morningstar9523
    @lucifer.morningstar9523 Рік тому

    1:01:34 Instead of creating list for each call we can return a clone of answer list and before returning we have to clear the answer list

  • @codeman0017
    @codeman0017 Рік тому

    yay! just completed the vedio,now I am confident in solving recursion problems

  • @beka3304
    @beka3304 Рік тому

    I think it's valid also: static List findAllIndex(int[] arr, int target, int index) {
    List list = new ArrayList();
    if (index == arr.length) {
    return list;
    }
    List belowCalls = findAllIndex(arr, target, index + 1);
    if (arr[index] == target) {
    belowCalls.add(index);
    }
    return belowCalls;
    } p.s but reversing indeces

  • @twi4458
    @twi4458 3 роки тому +1

    November 7, 2021: 101,000 subscribers. Thank you Kunal

  • @anirudhchakravarty6373
    @anirudhchakravarty6373 2 роки тому +7

    Between rotated binary search and recursive binary search which approach do we use in an interview? Love this course btw. Would love to see sliding window, 2 pointer, trees and graph questions

  • @dark.violin
    @dark.violin 11 місяців тому

    Your explanation is really great and I have so much fun watching your videos. Thank you for making a subject like Recursion understandable and entertaining for me.

  • @manishkasera8584
    @manishkasera8584 3 роки тому +2

    Return the arrayList without passing in the parameter ..
    Blow my Mind BRuuuuuuuuuuuuuuuuuuuuuuuuuuuuhhhhhhhhhhhhhhhhhhhhhhh.#3000

  • @animeshrose
    @animeshrose 2 роки тому

    Recursion is a cakewalk now! you have my support till the end of times.

  • @OjasRawat-v6o
    @OjasRawat-v6o 5 днів тому

    he is really giving his 100 percent ...

  • @himanshu_1422
    @himanshu_1422 3 роки тому +10

    Bhaiya please complete asap these course can't wait for more videos

    • @harishs2281
      @harishs2281 3 роки тому +2

      Yes kunal plz

    • @saibrinda8762
      @saibrinda8762 3 роки тому +3

      Yes my interviews are on the way 😶this is only hope for coding rounds...thanks for so far🙏

    • @prahmodhr3679
      @prahmodhr3679 3 роки тому +2

      Yes kunal pls finish the bootcamp asap

    • @brocklesnar4288
      @brocklesnar4288 3 роки тому

      No kunal bhaiya shouldn't hurry complete it fully

  • @jashhinger442
    @jashhinger442 2 роки тому +2

    See you later byeee, at 58:50 that's was so funny🤣🤣🤣 love the way you teach..❤❤🚀🚀

  • @RakeshChanda21
    @RakeshChanda21 Рік тому +1

    hey kunal! 1:18:47 in dry run you have showed indices are stored in descending order but the output is in ascending order how is it possible??

  • @meetsoni1938
    @meetsoni1938 3 роки тому +1

    The explanation of last question is amazing 🤩🤩💯💯

  • @cb-99-46
    @cb-99-46 2 роки тому

    now its getting easier for me to solve recursion problem ... thanks ...

  • @mrrishiraj88
    @mrrishiraj88 3 роки тому +1

    Good Day!
    Welcome back! Glad to see n hear you back!
    🙏👌👌

  • @sofiyarao815
    @sofiyarao815 2 роки тому

    guruji MIND IS BLOWN!

  • @ramanjain7284
    @ramanjain7284 Рік тому

    Great explanation especially from 52 minutes onwards concept

  • @siddharthdang1521
    @siddharthdang1521 3 роки тому

    concepts explained so well that I would remember for my lifetime

  • @abishekalwis3379
    @abishekalwis3379 5 місяців тому

    in the Q 01, sometimes there will be cases where index and index + 1 will have the same value. for that case make sure to use this arr[index] arr[i + 1]){
    return false;
    }
    }
    return true;
    }
    // using recursion
    public static boolean isSortedRecursion(int[] arr, int index){
    if (arr.length - 1 == index) {
    return true;
    }
    return arr[index]

  • @leecha9512
    @leecha9512 3 роки тому +1

    Awesome explanation and tutorials!!! You made Data Structures, Algorithms, and Recursion dead easy!!!! God bless you beta...

  • @poojasharma-cc5ur
    @poojasharma-cc5ur 11 місяців тому +1

    Please please make videos on DP and System Design kunal !

  • @amruthaa5876
    @amruthaa5876 3 роки тому +1

    WOWOWOW I understood the basics well now :D

  • @siamgithub7332
    @siamgithub7332 2 роки тому

    fun isSorted(arr: Array, prev: Int, next: Int): Boolean {
    if (next == arr.size) return true
    if (arr[prev] > arr[next]) return false
    return isSorted(arr, prev + 1, next + 1)
    }
    Can i call this as a pure recursion ? i mean when kunal said that question, immediatly this solution came in my mind

  • @coder_aditya9567
    @coder_aditya9567 3 роки тому +1

    Liked the video before watching...coz I know it's amazing ❤️❤️

  • @Setchuko
    @Setchuko Рік тому +1

    kunal its my request please make graph videos its really helpful for us...

  • @dineshmadduru7043
    @dineshmadduru7043 6 місяців тому

    Teaching in such a great way that I feel he's teaching some easy concepts. Thanks guruji

  • @suhaibalam1040
    @suhaibalam1040 Рік тому

    you made my life easy man. May the almighty GOD guide you to the right path.

  • @sheikhmkrifat7749
    @sheikhmkrifat7749 11 місяців тому

    Hats off kunal! take love from Bangladesh!

  • @ekemm
    @ekemm Рік тому +1

    hi
    1:03:11 here in line 86 the list.addAll(frombelowlist), the list we are talking about is the one that was created first (Suppose L1) in the heap memory, and all the other new lists (L2, L3 , L4 etc.) are just lying there useless. right?

  • @Videolyy
    @Videolyy Рік тому

    Best playlist for recursion🙌..

  • @Naturetheme-i9l
    @Naturetheme-i9l Рік тому

    u are the best in teaching broo that u for this course
    😘😘

  • @faizanshaikh3270
    @faizanshaikh3270 3 роки тому +3

    Do the OOP video ASAP. Because lots of courses do the oop in early part of the course.

  • @foyzanahmed4091
    @foyzanahmed4091 Рік тому

    array inside function body is the best part of the video;

  • @KaranSethia24
    @KaranSethia24 Рік тому

    This course is soo great, It will change your thinking unless you're dumb like me. I literally solved the rotated sorted ques by myself wrote cases on whiteboard , rand code with all test cases and forgot to print the ans🥲 and thought maybe im not ready or this is too much . Anyways thanks kunal

  • @vikaspanwar5194
    @vikaspanwar5194 3 роки тому +3

    Brother please try to increase the frequency of videos. we need to complete the DSA before placement season.

  • @iamjayandhan
    @iamjayandhan 2 місяці тому

    Building thought process! Man🔥

  • @sagarmore9425
    @sagarmore9425 2 роки тому

    Kunal is like, this is already covered this topic in the last video please check it out. I am not gonna teach you again.
    But he tries to teach that topic again, at least in short. :D
    Kudos to your efforts man.

  • @shafaq-here
    @shafaq-here 3 роки тому

    Debugging makes learning easier .
    Thanks for the tips .

  • @Content_creater_entertainment
    @Content_creater_entertainment 4 місяці тому +1

    This is what we need

  • @shafinnahian75
    @shafinnahian75 Рік тому

    "Hence, whenever you're adding a value in the list in different function call, value is being added in the original object. *WHY?*"
    "I can't explain it for the hundredth time. Watch the array lecture " with a disappointed stone cold stare right at the camera xDDDDDDDD
    This man's marketing and psychological game is par to none! xD Man, I love Kunal!

    • @shafinnahian75
      @shafinnahian75 Рік тому

      "Get some coffee, and pay attention. Please."
      This man, I swear, has the coolest psychological game in the industry xDD