Recursion - Array Questions (Theory + Code + Tips)

In this video, we cover #recursion questions that deal with arrays. This is an important video as it teaches you which technique to use when.
Things like passing arrays in arguments, returning arrays in recursion, creating local objects then sharing values, and more.
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:
0:00:00 Introduction
0:03:18 Q1 : Sorted Array
0:18:42 Q2 : Linear Search
0:27:09 Q3 : Linear Search (on multiple occurrences)
0:30:50 Q4 : Return an ArrayList
0:49:47 Q5 : Return the list without passing the argument
1:04:19 Q6 : Rotated Binary Search
1:17:52 Outro
#placement #dsa #interviews

Пікірлер: 418

  • @surajgupta3267
    @surajgupta32672 жыл бұрын

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

  • @teslatestingwala5019

    @teslatestingwala5019

    2 жыл бұрын

    He gets Powerfull blessings

  • @jayakumar9976

    @jayakumar9976

    2 жыл бұрын

    i can personal vouch for it!!..

  • @logeesh2009

    @logeesh2009

    2 жыл бұрын

    Agreed

  • @er.albertaddy2386

    @er.albertaddy2386

    2 жыл бұрын

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

  • @devincodes5218

    @devincodes5218

    Жыл бұрын

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

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

    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."😂

  • @vedantyt2451
    @vedantyt24512 жыл бұрын

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

  • @vittalmaheshwari5348
    @vittalmaheshwari53482 жыл бұрын

    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

  • @KunalKushwaha

    @KunalKushwaha

    2 жыл бұрын

    Glad to hear that!

  • @ankitpani6656

    @ankitpani6656

    2 жыл бұрын

    From Which College Are You?

  • @omkarjoshi7371

    @omkarjoshi7371

    2 жыл бұрын

    Offer from these playlist only? Yes no doubt good playlist.

  • @mycomputer1429

    @mycomputer1429

    2 жыл бұрын

    Your linked name please

  • @mycomputer1429

    @mycomputer1429

    2 жыл бұрын

    Links

  • @rakeshbabu4790
    @rakeshbabu47902 жыл бұрын

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

  • @sreejak6776

    @sreejak6776

    2 жыл бұрын

    Yes! I agree

  • @studyafa7159

    @studyafa7159

    10 ай бұрын

    Nhi hoga. 🧹🧹

  • @demonking7900

    @demonking7900

    10 ай бұрын

    ​@@studyafa7159why not

  • @_DashingAdi_

    @_DashingAdi_

    9 ай бұрын

    ​@@studyafa7159lul

  • @roshanchauhan1123

    @roshanchauhan1123

    7 ай бұрын

    F = 1 / T but T is regular speed so it will be saame

  • @budgetdapr
    @budgetdapr2 жыл бұрын

    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 жыл бұрын

    Glad I could help

  • @Kondlapudi

    @Kondlapudi

    2 жыл бұрын

    I agree!!

  • @panchanansahoo1463

    @panchanansahoo1463

    Жыл бұрын

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

  • @meetabhashiniparida9417

    @meetabhashiniparida9417

    Жыл бұрын

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

    9 ай бұрын

    @@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.

  • @projecthope2836
    @projecthope28362 жыл бұрын

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

  • @subhankarkanrar9494
    @subhankarkanrar94944 ай бұрын

    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

    Ай бұрын

    bro did you understand recursion completely from his videos?

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

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

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

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

  • @ishanvyas2178
    @ishanvyas21782 күн бұрын

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

  • @ashisbhowmik348
    @ashisbhowmik3482 жыл бұрын

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

  • @ujjwalkumar7267
    @ujjwalkumar72672 жыл бұрын

    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
    @sujithsaikalakonda48632 жыл бұрын

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

  • @Helly_Patel
    @Helly_Patel2 жыл бұрын

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

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

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

  • @aashashanmugam
    @aashashanmugam3 ай бұрын

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

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

    *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
    @dipeshjadhav15462 жыл бұрын

    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

  • @KunalKushwaha

    @KunalKushwaha

    2 жыл бұрын

    Thanks a ton

  • @siddharthdang1521
    @siddharthdang15212 жыл бұрын

    concepts explained so well that I would remember for my lifetime

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

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

  • @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

  • @chinmayatewari7589
    @chinmayatewari75898 ай бұрын

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

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

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

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

    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

  • @riyazahmadkhan9490
    @riyazahmadkhan94902 жыл бұрын

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

  • @manashbarman273
    @manashbarman2732 жыл бұрын

    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

  • @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❤❤❤❤❤❤❤

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

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

  • @imranjamshaid8708
    @imranjamshaid870811 ай бұрын

    what a Quality Lectures.I never seen on KZread

  • @AftabAlam-gh1nh
    @AftabAlam-gh1nh Жыл бұрын

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

  • @samuelmanukonda286
    @samuelmanukonda2862 жыл бұрын

    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.

  • @sameerakhatoon9508

    @sameerakhatoon9508

    Жыл бұрын

    yep, thanks!!

  • @rishabhrawat8197
    @rishabhrawat81972 жыл бұрын

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

  • @KunalKushwaha

    @KunalKushwaha

    2 жыл бұрын

    told ya

  • @leecha9512
    @leecha95122 жыл бұрын

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

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

    guruji MIND IS BLOWN!

  • @Virtualexist
    @Virtualexist26 күн бұрын

    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

    25 күн бұрын

    striver's playlist is complete unlike his

  • @Virtualexist

    @Virtualexist

    25 күн бұрын

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

  • @dark.violin
    @dark.violin6 ай бұрын

    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.

  • @vikaskumarnitrr
    @vikaskumarnitrr2 жыл бұрын

    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

  • @sharansukesh5542
    @sharansukesh55422 жыл бұрын

    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);

  • @ashaysaoji2273
    @ashaysaoji22733 ай бұрын

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

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

    Thank you so much Kunal, You made this so simple.

  • @twi4458
    @twi44582 жыл бұрын

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

  • @chayanbarman337
    @chayanbarman3372 жыл бұрын

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

  • @meetsoni1938
    @meetsoni19382 жыл бұрын

    The explanation of last question is amazing 🤩🤩💯💯

  • @pradeepella
    @pradeepella2 жыл бұрын

    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

  • @user-om7vk9gk5k

    @user-om7vk9gk5k

    Жыл бұрын

    bro not many all

  • @suryaganeshpindiprolu472
    @suryaganeshpindiprolu4722 жыл бұрын

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

  • @himanshu_1422
    @himanshu_14222 жыл бұрын

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

  • @harishs2281

    @harishs2281

    2 жыл бұрын

    Yes kunal plz

  • @saibrinda8762

    @saibrinda8762

    2 жыл бұрын

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

  • @prahmodhr3679

    @prahmodhr3679

    2 жыл бұрын

    Yes kunal pls finish the bootcamp asap

  • @brocklesnar4288

    @brocklesnar4288

    2 жыл бұрын

    No kunal bhaiya shouldn't hurry complete it fully

  • @yaswanthkosuru
    @yaswanthkosuru2 жыл бұрын

    these playlist of recursion deserve million of views

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

    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

    Жыл бұрын

    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.

  • @PriyaSingh-zb5wn
    @PriyaSingh-zb5wn3 ай бұрын

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

  • @thanushkrishna2041
    @thanushkrishna20412 жыл бұрын

    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 !!

  • @abishekalwis3379
    @abishekalwis337911 күн бұрын

    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]

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

    WOWOWOW I understood the basics well now :D

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

    THANK YOU KUNAL for such an amazing content

  • @sauravagrawal5013
    @sauravagrawal50139 ай бұрын

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

  • @SatyaSaiPrasad-ot4jl

    @SatyaSaiPrasad-ot4jl

    20 күн бұрын

    😄

  • @poetryiscodingdecoding7965
    @poetryiscodingdecoding79652 жыл бұрын

    One of the finest content of the globe today

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

    amazing content Kunal, thank you. Waiting for season two :)

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

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

  • @KunalKushwaha

    @KunalKushwaha

    Жыл бұрын

    You’re welcome

  • @immayurpanchal
    @immayurpanchal2 жыл бұрын

    Hey Kunal. Watched your Level 1 Questions video on Recursion and was able to solve one interview questions that I was asked in my interview. Unfortunately, I watched the video after the interview. But no worries. Really the way you're solving questions and explaining the thought process is really really beneficial. I also want to tell you that in the video you sometimes tell that it's too easy and doesn't feel like doing it but still you write the code and explain it. Please do that. It seems too easy for you but it's too difficult for people like me who are not that good at recursion. As you've solved those dumb questions and explained them. Hence, I was able to do some other questions also. This is helping me how to think in recursion. You're doing a fantastic job man! Excited to see your DP, Graph, Tree videos. ❤ I'm happy to tell you that you're not like other KZreadrs and share incomplete knowledge. Kudos to your hard work ☮ 😃

  • @animeshrose
    @animeshrose2 жыл бұрын

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

  • @KunalKushwaha

    @KunalKushwaha

    2 жыл бұрын

    Thank You

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

    Love your teaching ❤️

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

    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

  • @mayank3411
    @mayank34118 ай бұрын

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

  • @pratibhasharma4012
    @pratibhasharma40122 жыл бұрын

    A big thanks Kunal..for qauality content and with nice explaination

  • @FaizanFurqan034
    @FaizanFurqan0345 ай бұрын

    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 ❤

  • @LowkeyCoder
    @LowkeyCoder11 ай бұрын

    best best best especially i was confused at the begining that how the list is geeting returned empty but now its clearer than ever thank you sir 1:02:00.

  • @ankitgiri8394
    @ankitgiri83942 жыл бұрын

    Thanks kunal❤😎💯

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

    This is GOLD❤

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

    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

    Жыл бұрын

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

  • @techstar3850
    @techstar385010 ай бұрын

    Great Video. Highly recommended!.

  • @user-hm6mv6bx3e
    @user-hm6mv6bx3e5 ай бұрын

    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.

  • @coder_aditya9567
    @coder_aditya95672 жыл бұрын

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

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

    you make my day man, thanks 🙏

  • @shafaq-here
    @shafaq-here2 жыл бұрын

    Debugging makes learning easier . Thanks for the tips .

  • @romanaqureshi7215
    @romanaqureshi72152 жыл бұрын

    Thanks for the great explanation Kunal..

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

    best explanation ever

  • @shivakumarkonga1532
    @shivakumarkonga15324 ай бұрын

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

  • @aayushojha3088
    @aayushojha30882 жыл бұрын

    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!!

  • @KunalKushwaha

    @KunalKushwaha

    2 жыл бұрын

    Glad I could help!

  • @charanteja4619
    @charanteja46197 ай бұрын

    Bro simply increasing competition in the Industry!

  • @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

  • @KunalKushwaha

    @KunalKushwaha

    Жыл бұрын

    You’re welcome

  • @khalidalnhdy9776
    @khalidalnhdy97769 ай бұрын

    Kunal, you are the best ♥

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

    Thanku kunal sir

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

    brilliant concept explained in detail.🤖

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

    thanks a lot, no words to describe.

  • @Hello1335
    @Hello13354 ай бұрын

    Really loved the video 😍

  • @sheikhmkrifat7749
    @sheikhmkrifat77495 ай бұрын

    Hats off kunal! take love from Bangladesh!

  • @saiakshayyellampalli2599
    @saiakshayyellampalli25992 жыл бұрын

    Super explaination about array lists in recursion

  • @ShivamPandey-jc8rh
    @ShivamPandey-jc8rh2 жыл бұрын

    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 .

  • @Saeed-Tanjim
    @Saeed-Tanjim Жыл бұрын

    great tutorials man! Thanks a lot

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

    Your courses are the reason I bought KZread premium😊

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

    GREAT EXPLANATION

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

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

  • @foyzanahmed4091
    @foyzanahmed40919 ай бұрын

    bro You just drill my brain. You 😍😍😍r a magician

  • @ramanjain7284
    @ramanjain728411 ай бұрын

    Great explanation especially from 52 minutes onwards concept

  • @baravi2005
    @baravi20052 жыл бұрын

    Can I do a one time payment (instead of monthly subscription)? Brilliant videos...absolutely loving them. I think what's amazing about them is the way the skills are being built up incrementally (like progressive overload for gaining muscle) -this is the key to mastering any skill/subject :)

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

    Hats off to u bhsi gem content

  • @user-vr4ho7zx8c
    @user-vr4ho7zx8c4 ай бұрын

    Intersting explaining, thank you.

  • @faizanshaikh3270
    @faizanshaikh32702 жыл бұрын

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

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

    you are the best bro

  • @Iam_number_one
    @Iam_number_one8 ай бұрын

    THANK YOU SIR !