19 Longest common subsequence Recursive

Поділитися
Вставка
  • Опубліковано 4 лют 2020
  • Longest Common Subsequence Problem solution using recursion
    Given two sequences, find the length of longest subsequence present in both of them.
    A subsequence is a sequence that appears in the same relative order, but not necessarily contiguous.
    For example, “abc”, “abg”, “bdf”, “aeg”, ‘”acefg”, .. etc are subsequences of “abcdefg”.
    PROBLEM STATEMENT LINK: www.geeksforgeeks.org/longest...
    Playlist Link: • Dynamic Programming | ... .
    ------------------------------------------------------------------------------------------
    Here are some of the gears that I use almost everyday:
    🖊️ : My Pen (Used in videos too): amzn.to/38fKSM1
    👨🏻‍💻 : My Apple Macbook pro: amzn.to/3w8iZh6
    💻 : My gaming laptop: amzn.to/3yjcn23
    📱 : My Ipad: amzn.to/39yEMGS
    ✏️ : My Apple Pencil: amzn.to/3kMnKYf
    🎧 : My Headphones: amzn.to/3kMOzM7
    💺 : My Chair: amzn.to/385weqR
    🛋 : My Table: amzn.to/3kMohtd
    ⏰ : My Clock: amzn.to/3slFUV3
    🙋🏻‍♀️ : My girlfriend: amzn.to/3M6zLDK ¯\_(ツ)_/¯
    PS: While having good gears help you perform efficiently, don’t get under the impression that they will make you successful without any hard work.

КОМЕНТАРІ • 405

  • @shaunakdas4921
    @shaunakdas4921 4 роки тому +475

    bro, you will go way further if you take the path of teaching programming. I have seen alot of tutorials ,some paid and some free content in youtube. But no one teaches programming like you do. It's because you are teaching how to think like a coder which is very rare. Keep it up.

    • @TheAdityaVerma
      @TheAdityaVerma  4 роки тому +96

      Thanks brother, Do subscribe and share, that keeps me motivated to do more !!

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

      @Jacob Noe fuck you scammers, google shows your scams

    • @vivekbaghela7572
      @vivekbaghela7572 3 роки тому +33

      @@TheAdityaVerma bro you should mention in every vid that you have mistaken top-down for bottom-up, this will help your channel grow more, bcz jo bina recommendation aaye honge wo log vid shayad puri hi na dekhe soche ki galat pdha rha h, ik unka bad luck. But you must add a frame or something else in each vid about this correction!

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

      Can anyone explain why we increase the length by 1 when we have common character in both the string? I mean there might be a case wherin the LCS doesn't have the same character but we included it in our solution

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

      @@sachinarora6682 because we need the count like how much is common. so if there is a match we have to count somewhere to get the count as 4.
      if there is no match it will not come inside that condition and answer would remain 0 hope you are talking the one explained at #23:11

  • @soumikroy4600
    @soumikroy4600 4 роки тому +157

    Brother you'r red coder in teaching programming.

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

      Can anyone explain why we increase the length by 1 when we have common character in both the string? I mean there might be a case wherin the LCS doesn't have the same character but we included it in our solution

    • @ABCD-gn5uw
      @ABCD-gn5uw 2 роки тому

      @@sachinarora6682 we would only increase that if there's a match. because if theres a match than definitely we would have something in common. if there's no match we will return for the rest of the substrings.

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

      @@sachinarora6682 we increase length by 1 as we know the first common character from the end will definitely be in the longest common subsequnce. This is due to the fact that we are looking at it from the end and not the beginning. So no matter what the length of the LCS is between x[0....n-2] and y[0.....m-2], if you add the last common character among the strings (which is x[n-1]) it will create a longer LCS with length one greater than the previous LCS. I probably think you have mistaken subsequence for substring but by looking at your other comments, that doesnt seem to be the case. Just think of it like this -> Prefix substring of x[0...n-1] iis equal to x[0...n-2]. Let LCS of prefix substrings of x and y be of length L (assume it is the most optimal i.e longest subsequence). Now, if the suffix characters are equal (i.e x[n-1]==y[m-1]), then they can be added to the LCS of the prefixes to make a "longer" LCS and this "longer" LCS will be the LCS of the full strings x and y. Simple as that :D

  • @ankitsoni3388
    @ankitsoni3388 4 роки тому +105

    Bhai currently I am working at one of the MNC but one thing I learned that to survive in IT sector you just cannot stop practicing DS Algo, I always was a little weak in recursion and had no idea about DP. Even during placement season I somehow memorized first 20 Standard DP questions from geeks, but since the day I started watching your dp playlist, I must admit my life has become easier, recursion and DP feels too easy. Kudos to you . Thanks a lot.

    • @TheAdityaVerma
      @TheAdityaVerma  4 роки тому +17

      Thanks brother, If you like the content please do share where ever you feel right to help the channel grow !!

  • @deekshithanand3094
    @deekshithanand3094 3 роки тому +282

    I genuinely request all others to watch his lectures by disabling Adblock(if u have any)!!! It's worth it supporting this channel! Its light years ahead of other lectures!!! Thanks a lot Bhai for the content!!!!!!

    • @TheAdityaVerma
      @TheAdityaVerma  3 роки тому +114

      Brother, This comment is love ❤️ Its really hard to find guys like you these days. Respect !!

    • @bhavikmehta7193
      @bhavikmehta7193 3 роки тому +43

      thanks for giving idea of using adblock

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

      @@bhavikmehta7193 lol

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

      I do the same... keep the ads coming :)

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

      @@binod3204 binod spotted 😂😂

  • @shireenabraham8627
    @shireenabraham8627 4 роки тому +84

    Hands down best DP tutorial ! I'm so glad the number of subscribers are increasing everyday

  • @taylorrocks45
    @taylorrocks45 4 роки тому +136

    I could actually write the solution on my own by deriving from the concepts taught in Knapsack. Thank you so much for these tutorials. Wish you the success that you truly deserve.

    • @vikashprasad3279
      @vikashprasad3279 4 роки тому +7

      Exactly that's what i was gonna write here😂😂 his teaching skill is awesome ❤️

    • @thisishunayn
      @thisishunayn 4 роки тому +10

      Same DP seems easy now, but Ill have to work on recursion now.😂

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

      @@thisishunayn Coin change problem: Minimum number of coins

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

      agreed. he teaches in a way that you develop your intuition about dp

  • @0anant0
    @0anant0 3 роки тому +42

    19 of 50 (38%) done! Very good explanation and revision of recursion steps. It has become so easy that I can tell what you are going to say next -- it means you taught very well in earlier videos :-)

  • @techguybiswa
    @techguybiswa 4 роки тому +4

    Hands down the best LCS tutorial on all of youtube!

  • @Vendettaaaa666
    @Vendettaaaa666 4 роки тому +12

    I have never seen a neat technique like this to build recursive solutions! You should teach backtracking as well in the same way! I could always build recursive solutions by building up the whole call stack in tree format and then identify "choices" and "base cases", but I see how you can "abstract" this thinking out.
    Your technique is also better because sometimes, you might have a really huge call stack tree, depending on inputs you choose to come up with recursive solution.

  • @abhishekupadhyay4954
    @abhishekupadhyay4954 4 роки тому +1

    I have never liked DP this much.I have solved most of the DP questions in these two days after watching your videos. Great work!!

  • @sourabhkumar6194
    @sourabhkumar6194 4 роки тому +1

    I have read articles on LCS many times , but the way you taught LCS ..it was just great...keep it up big bro never stop.

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

    Loving the content you put out man! Please also put out a series on Graph problems as well :) I feel knowing BFS, DFS is different from actually applying them in the problems like number of islands etc.Please make a series of videos on them as well

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

    Bought *GFG Paid DSA Self Paced* course it is slow as fuck, I will not say it is not good but man nothing compared to this.....You made me feel that I am able to do coding. Else I was feeling like a crap for almost a year now. Thankyou and love u brother.

  • @easycoding591
    @easycoding591 4 роки тому +7

    Now i got why you are SDE in Flipkart. You are awesome man.

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

    These Questions were like a nightmare to me, but because of you, I designed a top-down version of this question on my own.
    Thank you, bro.

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

    Thanks bro. I was so afraid of ds, algo. But because of your teaching I've overcome my fear to some extent. Keep growing!!!

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

    You are the hero that we need, but don't deserve. Thank you so much for this content.

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

    The best way of teaching using just pen and paper. Thanks for teaching!

  • @brownchocohuman6595
    @brownchocohuman6595 3 роки тому +14

    The pens you use sound so satisfying 😍
    You should bring out your ASMR series too with them 😂

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

    Excellent Explanation !! .. Thank you so much !! ..Best DP explanations so far on UA-cam.

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

    I seriously can't believe how easy it was to understand this just because of the previous videos. You rock man! 😎🙇‍♀️ Thanks a lot for such amazing videos. 😍🙌

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

    One day I want to solve questions like you do and with your clarity and understanding level.

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

    this channel deserves all the love there is in the world!!

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

    oh man, your teaching style is just too good, pls make the same content for trees and graphs too

  • @sheebapradhan2138
    @sheebapradhan2138 4 роки тому

    You make everything easier than I used thought. Best dp tutorials!!! Thnks a lot🙌

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

    Simply awesome!. Never seen anyone explaining so well like you do Aditya!.. Amazing!..

  • @AdityaSingh-ql9ke
    @AdityaSingh-ql9ke 2 роки тому

    Ur explanation, of subsequence vs subarray, just shows that u r teaching from the ground up, without presuming that people will understand it anyways. Amazing 🤘🤘

  • @amitsamui4958
    @amitsamui4958 3 роки тому +4

    Bhaiya ,your knapsack explaination is so good that I figured out this question in just 5min of starting.....thankyou bhaiya my thinking skill in recursion is increasing

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

    Your videos are very easy to understand and also cleared many misconceptions I previously had. Thank you very much

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

    Thank you for putting so much efforts in putting these solutions and most importantly teaching them the right way.

  • @deepak-ly3ob
    @deepak-ly3ob 6 місяців тому +1

    The guy who has made the dp easier is the Aditya Verma..... He has made the dp like halwa. Concepts are too easier to understand. Thank you Sir.

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

    this whole series is a gem

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

    its amazing all ur lectures are far better than any other content i have ever seen regarding programming. Hope to see more contents from u.. I am aiming to finish ur each and every playlist .

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

    I was struggling with LCS for quite a long time. You really cleared it up. Thanks. Keep it up. One feedback though. Please mention time and space complexity as well.

  • @jasmeen2541
    @jasmeen2541 4 роки тому +1

    You are just amazing!!!❤
    Can't thankyou enough for such amazing explainations!
    Really thankyou very much, you made DP the best!🙌

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

    Thank you very much sir . Sir main iss video ko 2022 mein dekh raha hoon, lekin jitna simplify karke aur thinking approach aapne bataaya hai, utna mujhe aur kahin nahin mila.

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

    Amazing teaching sir. Beyond appreciation. Please don't stop posting videos.

  • @nihaljaiswal1839
    @nihaljaiswal1839 4 роки тому

    I had watch lots of lecture of recursion and dp but I always be confused in these topic but watching these video lecture series made me clear each concept of recursion & DP from basic to advance level

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

    I wrote the solution with my own by using the concepts you taught in previous lectures. Thanks you so much

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

    Bro your teaching skills are great ❤️.Please come up videos covering all the DS algo topic .we really need it .You are better to then any course either paid or free

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

    the way you breakdown each and every key term is very good very few youtubers focus on this. 😍

  • @pasitopasito1967
    @pasitopasito1967 4 роки тому

    Bhai jaha tak.mene search kara hi dp youtube me ,,abhi tak aisa channel nahi mila ...thanks a lot

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

    thanks a lot aditya, ab toh aage yeh problem khud hi hojaegi, all credit to you for this confidence!

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

    nice of you to go through the whole process !

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

    my trainer recommended me your lecture. Your approach to the problem is good

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

    this is the best lecture of LCS this is really really helpful for the beginner in programming thank you so much for this amazing DP series 💯💯

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

    I solved it myself. All thanks to you. You are the best.

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

    Bro, after watching your videos I feel I can also solve problems in DSA.
    Before , I was not able to solve a singel question in DP.
    Keep up the good work.
    Salute to you ...
    Make some videos on graph.

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

    you wont find a better explanation for LCS anywhere. Thanks a lot aditya!

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

    shabd kam hai apke liye..... One of the best teacher!!!!!

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

    Such a good video.. Dynamic programming is really hard and confusing concept. The way u explained the concepts, made it look easy

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

    Best DP course on internet!

  • @hnsoni4
    @hnsoni4 3 роки тому +4

    Abe ye dislike walo sharam karo thodi. Itna effort lagake ye video bana raha wo bhi world class, bc na to tum support karte ho ulta dislike kar dete ho. @Aditya Bhai keep it up. We will always support the good deed (And please Complete the series with missing and private videos.
    I came here after watching Recursion Playlist to iska recursion design karna was a piece of cake as you promised at the end of the playlist. Thank you very much. God bless you.

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

    Your teaching style is awesome, Aditya. Please provide some tutorials on Kadane and LIS too

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

    Brooooo you're the best!!! Please add videos on DP on graphs and backtracking also!!!! Thanks a ton for your effort!!

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

    I feared these kind of LCS derivatives, I on my own developed the right intuition to solve this one using previous problems, felt so good !

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

    Excellent Explanation
    Thank you Aditya Verma

  • @ManpreetKaur-rf2yh
    @ManpreetKaur-rf2yh Рік тому

    u r the best guide one could ask for... lots of love

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

    Ioved your teaching approach I hope you know every bit of technology everything, so that you break it down for us. I have been trying to get my head on machine learning if there is any chance you coming up with lectures! 😇 Or recommended me some your best pick course on ML.

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

    I was able to solve this problem on my own because of your previous videos THANK YOU

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

    literally! the best . strongly recommended for first year and second year students

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

    Awesome explanation, very intuitive explanation with choice diagram and base case.

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

    Bhai knapsack dekhne ke bad and uspe questions krne ke bad, iski choice diagram, maine khud se banai and bad me tumhara video dekha to maine ye paya ki mera brain evolve ho chuka hia. bro.
    Bahut acha lag rha ma kasam
    Maza aagya

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

    Beautiful work. Thank you.

  • @kapil16garg5
    @kapil16garg5 4 роки тому +1

    sir,,,you are awesome... bestest tutorial of DP

  • @SwikarP
    @SwikarP 10 місяців тому

    Best of the best of the best. I am preparing for Amazon, JP Morgan Chase Interview. Helps a lot Thank you

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

    Fantastic teaching bro... I was terrified of DP... Now they have become way simpler.. grateful to you
    I guess people will be willing to pay for these videos.
    I have downloaded the playlist just in case. 😛

  • @adityaprakash4955
    @adityaprakash4955 4 роки тому +11

    keep doing this good work... please start graph also

  • @pratyushbhatt1712
    @pratyushbhatt1712 3 роки тому +4

    If anyone is thinking examples like in strings abcd
    and abedcg , what is the length of longest common subsequence, if you're thinking that LCS length here is 4, as a,b,c, and d all are present in both the strings, then you're wrong... Because--" A subsequence is a sequence that appears in the same relative order, but not necessarily contiguous." I had the same doubt. Hope I helped someone. Peace out!

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

    thank you sir, great explanation.

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

    Over 1 lakh views and only 3.8k likes :(
    This guy deserves more likes guys because of this wonderful explanation for the whole dp series.

  • @aurevoir6879
    @aurevoir6879 4 роки тому +1

    Nice explaination brother. Please cover Graph and Trees as well. It would be really helpful to learn from you . Great concept clarity.

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

    When would you complete this playlist? I have been relying on this to gain my DP knowledge. Please complete it. Thanks for all the tutorials you have created. Much appreciated

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

    awesome and simple explanation!! THANK YOU SO MUCH

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

    Kya mast sikhaya bhai ! I wish I could tag my imbecile teachers here. They should learn from you. You definitely know how to break down concepts easily. Aditya Verma supremacy !!

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

    I am able to develop this solution by my own because of you 😊thanks brother

  • @techguybiswa
    @techguybiswa 4 роки тому

    REally really nice tutorial!!!!

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

    Awesome teaching of coding there are many institutions that take huge 💰 but not teach even 20percent of ur quality teaching ....Bro U make course on compitative coding(complete) that ill make ur channel...grow in million believe me.....

  • @AmitKumar-yq3lx
    @AmitKumar-yq3lx 3 роки тому

    Thank you for such a great job !!!

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

    The best explanation I have ever seen

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

    The best explanation i have ever seen. Thanks Aditya Bhai

  • @rohitjoshi6335
    @rohitjoshi6335 4 роки тому

    cant describe in words Great Explanation!!!!

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

    recursion toh jadhu hai bhai...love you bhai

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

    with so much dedication and passion I have not seen anyone teach like this its like my elder bro is teaching me a big Thanks to you, mera dp ka daar dur karne ke lea

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

    the way u teach , I can never forget any concept

  • @sahilkansal288
    @sahilkansal288 2 роки тому +6

    Hi, I think you should also mention the algorithm complexity of both(recursive and dp) solutions also.

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

    Big Fan Sir!! apka "SUM UP" Style bahut achha he !!! itna achha ki sirf sum up bhi dekha to bhi sab kuch samaj a jaye!!! :)

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

    Wow.. You are really talented teacher... Great explaination👌👌

  • @Raj-sz9pg
    @Raj-sz9pg 3 роки тому

    I think use are very great sir. I would like to sit in your class for hours learning this stuff.
    Online concentration is hard though

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

    One of best tutorial bro .. hats off t you

  • @NoName-lq7xk
    @NoName-lq7xk 2 роки тому

    You are a teacher material ❤️

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

    Done this question with the intuition of edit distance and it got accepted in gfg thanks for another approach. Bro your videos are lit 🔥🔥🔥🔥🔥🔥🔥🔥🔥🎉🎉🎉🔥🔥🔥🔥🔥🔥🔥🔥

  • @MMNayem-dq4kd
    @MMNayem-dq4kd Рік тому

    thank you.Your contents are just masterpiece

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

    Esa content kahi nhi dekha ek number !

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

    Sir your teaching style 110/100

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

    Silver button on its way.. Congratulations..

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

    You made me fall in love with DP!

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

    Very nice teaching style!!

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

    Ekdum Hila Dala 🔥🔥🔥🔥

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

    Bhai kya badhiya explain kiya hai, thank you so much