Dp 25. Longest Common Subsequence | Top Down | Bottom-Up | Space Optimised | DP on Strings

Sdílet
Vložit
  • čas přidán 28. 02. 2022
  • Lecture Notes/C++/Java Codes: takeuforward.org/dynamic-prog...
    Problem Link: bit.ly/3pvkqUd
    Pre-req for this Series: • Re 1. Introduction to ...
    a
    Make sure to join our telegram group for discussions: linktr.ee/takeUforward
    Full Playlist: • Striver's Dynamic Prog...
    In this video, we solve the LCS Dp, this is the first problem on the pattern Strings on DP.
    If you have not yet checked our SDE sheet, you should definitely do it: takeuforward.org/interviews/s...
    You can also get in touch with me at my social handles: linktr.ee/takeUforward

Komentáře • 754

  • @art4eigen93
    @art4eigen93 Před rokem +151

    In the future, Mr. Vikramaditya will go down as the G.O.A.T online DSA teacher.

  • @manthenanagendra1077
    @manthenanagendra1077 Před rokem +119

    putting your years of hardwork in some videos ,how lucky we are,Thanks a lot striver bhaiya for everything you are doing for us

  • @anweshabanerjee6241
    @anweshabanerjee6241 Před rokem +64

    If someone is following Striver's series then this LCS is also a cakewalk..#Striver gives u confidence and you are no longer scared of dp😁

  • @sujalgupta6100
    @sujalgupta6100 Před rokem +64

    46:05 for space optimization we don't require the loop for prev as the values are already zero in it.

  • @pratyakshsinha6292
    @pratyakshsinha6292 Před rokem +129

    Understood and you've completely changed my life. Doesn't matter if I get placed in a good company or not but the quality of this lectures are supreme and I will carry this knowledge for rest of my life.

    • @AdityaKumar-be7hx
      @AdityaKumar-be7hx Před rokem +16

      Keep trying. It will work out. Dream for the day when you are so good that you REJECT your dream company.

    • @iamnoob7593
      @iamnoob7593 Před 6 měsíci

      @@AdityaKumar-be7hx Requires god level consistency to do that.

    • @idris110
      @idris110 Před 5 měsíci +1

      You will probably forget the concepts, since these are never used in the industry. What a satire !

    • @bharatravihal9646
      @bharatravihal9646 Před 5 měsíci

      🤣🤣@@idris110

    • @spoidy2025
      @spoidy2025 Před 3 měsíci

      brother are you placed

  • @arjundevmishra7207
    @arjundevmishra7207 Před 10 měsíci +43

    Protect this guy at all costs. Thank you sir for all your hard work in making this video.

  • @kartiksuman9814
    @kartiksuman9814 Před 2 lety +52

    understood bhaiya!!! after a very long time i am back to your channel....previously i was doing a race that as soon as you upload the video, i should watch it then n there, before the next video gets uploaded in this dp series, but due to some busy schedule, i lost the race. yeah, but your quality and energy is still the same as your starting videos

  • @Amitchoudhary-ij4we
    @Amitchoudhary-ij4we Před rokem +13

    I am very grateful to you for uploading this playlist. This is great!!!!!!!!!!!!!!!!!!!!!
    Understood.

  • @arunkumarsahoo1344
    @arunkumarsahoo1344 Před rokem +14

    15:34 "You kow i am hearing you" in the background

  • @donno2423
    @donno2423 Před rokem +10

    I used to be scared of Dp when I started coding journey, but when I am actually doing it, it's cake walk. Thankyou striver for sharing your knowledge.

  • @yashsinghal3404
    @yashsinghal3404 Před 2 lety +5

    What an easy explanation, loved it !

  • @ramanahlawat398
    @ramanahlawat398 Před rokem +4

    bro!!!!!! What an explanation, absolutely brilliant. I am starting to love coding now. Thanks

  • @avimandavia6154
    @avimandavia6154 Před rokem +5

    No other video on the topic will offer you a better explanation than this! This is just pure teaching excellence! Subscribed.

  • @mahammedhashish9170
    @mahammedhashish9170 Před rokem +1

    You can't find better explanation than this, Brilliant!!

  • @duyhuynh1234
    @duyhuynh1234 Před rokem +4

    You're a great teacher. If possible, please do problems about DP on tree. I struggle with them. Thank you!

  • @BG-lj6fw
    @BG-lj6fw Před rokem

    understood.wonderful. amazing. hats-off. unmatchable.

  • @stith_pragya
    @stith_pragya Před 6 měsíci +1

    UNDERSTOOD.....Thank You So Much for this wonderful video............🙏🏻🙏🏻🙏🏻🙏🏻🙏🏻🙏🏻

  • @nottheradbrad184
    @nottheradbrad184 Před 10 měsíci

    bro striver you have taught so well that i didnt even need to watch the video,i solved the problem in all three ways,thaank you very much❤

  • @cinime
    @cinime Před 2 lety +1

    Understood! Awesome explanation as always, thank you very much!!!

  • @ankita716
    @ankita716 Před 10 dny +1

    understood, always in awe of you genius and hard working you are:)

  • @pratapsingh9638
    @pratapsingh9638 Před rokem

    Understood,you are doing the great job , very thankful to you

  • @monojittewari6495
    @monojittewari6495 Před rokem +2

    absolutely minds bogling.i am not kidding i wasn't able to solve simple recusion questions few weeks ago now i can solve medium and hard dp questions on my own without watching videos.all i can say thank you striver.

  • @akashyadagouda896
    @akashyadagouda896 Před 5 měsíci

    Its taking while to digest this information for me ,
    Just imagine the efforts this guy is adding to make it available for everyone.

  • @ranasauravsingh
    @ranasauravsingh Před 2 lety +2

    UNDERSTOOD...
    Thanks striver for the video... :)

  • @sameersahu4569
    @sameersahu4569 Před 2 lety

    Loved the Explanation!!Understood

  • @ritikshandilya7075
    @ritikshandilya7075 Před 11 dny

    Thanks for great explanation striver

  • @ahsanulanam-4632
    @ahsanulanam-4632 Před 6 měsíci

    Dhonnobad Brother
    You are great

  • @DevashishJose
    @DevashishJose Před 6 měsíci

    Understood, Thank you so so much.

  • @shivamsinghnegi1192
    @shivamsinghnegi1192 Před rokem

    Thanks bro the Playlist is top notch...am getting a lot better...Thanks again

  • @Nikhil-ov6sm
    @Nikhil-ov6sm Před rokem

    awesome, understood..was pretty easy due to what you've alrready taught

  • @dashsights4258
    @dashsights4258 Před rokem

    Just one word , Beautiful!

  • @deepurana6010
    @deepurana6010 Před rokem +1

    You are amazing ❤️.
    Thanks a lot for this valuable content 🙌🙇🙇

  • @varunsharma1889
    @varunsharma1889 Před 2 lety

    Very good explanation. Understood. Thanks.

  • @gyanunlimited740
    @gyanunlimited740 Před 2 lety +5

    Man the content is gold.

  • @alokbhowmik3547
    @alokbhowmik3547 Před 2 lety +1

    what an explanation thanks for your time and such video

  • @sanyazaveri4511
    @sanyazaveri4511 Před rokem

    Awesome lecture. Understood!

  • @daniel.w8112
    @daniel.w8112 Před rokem

    Thank You Very much Striver !

  • @virgarg1012
    @virgarg1012 Před 18 dny +1

    Giving my best shot for preparing for my placements. Let's see what happens in upcoming months. Great Content

  • @user-oi6eb7ru2s
    @user-oi6eb7ru2s Před 7 měsíci

    Thanks a lot striver

  • @jskr456
    @jskr456 Před 6 měsíci

    very good explanation

  • @oqant0424
    @oqant0424 Před rokem

    seriously you are a legit!
    understood ,thanks🙌

  • @arnabroy2995
    @arnabroy2995 Před rokem +3

    US ❤
    I should mention I am solving DSA consistently from past 1 year. Encountered this question a lot of times.
    But till date this is the best explanation boss❤

  • @jaideeppyne1880
    @jaideeppyne1880 Před rokem

    very well explained step by step

  • @pj-nz6nm
    @pj-nz6nm Před rokem

    hey man i know you are a very good teacher , but you are also a very good human being.

  • @abdallaalhag4425
    @abdallaalhag4425 Před 6 měsíci

    Understood boss man!

  • @sypher4735
    @sypher4735 Před rokem +6

    I’m just so thankful to you for this wonderful series, I’m honestly enjoying it dude, surely you’re one of the best!
    I even did the problem by myself so easily, i was shocked believing😂

  • @CodeMode9313
    @CodeMode9313 Před 9 měsíci

    awesome paaji

  • @ChutHunter
    @ChutHunter Před 4 měsíci

    Thank you so much bhaiya, I always heard of this question as one of the most difficult ones. But by following your DP series, I did it on my own. You can easily sell this quality content for ₹ 50k but you're giving it for free. BEST TEACHER EVER ♥♥♥♥

  • @harisai3580
    @harisai3580 Před 5 měsíci

    Understood Sir!

  • @yashchawla3729
    @yashchawla3729 Před 2 lety

    Understood, sir. Thank you very much.

  • @santoshb7776
    @santoshb7776 Před 7 měsíci

    Understood sir ! 🙏🙏

  • @jashhinger442
    @jashhinger442 Před rokem

    Love the concept ✨

  • @user-ke7fs7ds6h
    @user-ke7fs7ds6h Před 6 měsíci

    GOAT for a reason❤❤

  • @rohan8758
    @rohan8758 Před 18 dny +1

    Nice explanation raj bhaiyan or dude, I might call you angel!🥰🥰

  • @ganeshkamath89
    @ganeshkamath89 Před 2 lety

    Thanks Striver. Understood LCS.

  • @rishabhgupta9846
    @rishabhgupta9846 Před rokem

    understood,previously I mugged up the tabulation formula for the exam ,but now I know how it came.

  • @prabhakaran5542
    @prabhakaran5542 Před 3 měsíci +1

    Understood ❤

  • @lakshmanpadigala1605
    @lakshmanpadigala1605 Před rokem

    Great explanation!

  • @prakharchandrakar6172
    @prakharchandrakar6172 Před 8 měsíci

    understood !!

  • @SethuIyer95
    @SethuIyer95 Před 3 měsíci

    I deeply understand recursion, memoization, tabulation and space optimization.

  • @saurabhrthakur
    @saurabhrthakur Před 2 měsíci

    Understood!

  • @HarshSharma-ff3ox
    @HarshSharma-ff3ox Před rokem +5

    Thank you Striver for such a wonderful explanation. Finally understood it intuitively. 💯💯

  • @raj_kundalia
    @raj_kundalia Před rokem

    thank you so much!

  • @ishitakansal2345
    @ishitakansal2345 Před 4 měsíci

    Understood 🤩🤩

  • @priyanshuchouhan9845
    @priyanshuchouhan9845 Před 9 měsíci

    one of the best dp series

  • @UECAshutoshKumar
    @UECAshutoshKumar Před 12 dny +1

    Thank You
    Understood!!!

  • @varunbansal1136
    @varunbansal1136 Před 8 měsíci +1

    If someone is using java to write the code, in space optimization approach there will be error in a testcase, to resolve that error replace prev = curr with prev = curr.clone(); or else use the code snippet
    int [] temp = prev;
    prev = (curr);
    curr = temp;
    Because in java prev = curr will not create a new array but it will point both the references to same address.
    Your program would work fine.

  • @m4n0jkum4r
    @m4n0jkum4r Před rokem +1

    In Tabulation we are declaring vector with values zero. So we can skip first two loops.

  • @lambar0
    @lambar0 Před rokem

    Clear and Simple

  • @Jagz1200
    @Jagz1200 Před 11 měsíci

    Love you bro :) you are saviour!

  • @thanhbinhnguyen5943
    @thanhbinhnguyen5943 Před rokem +1

    nice explaination !

  • @codewithpranjay9618
    @codewithpranjay9618 Před 2 lety

    understood well !

  • @rishabhagarwal8049
    @rishabhagarwal8049 Před rokem

    Understood Sir, Thank you very much

  • @RezaulKarim-cq5ft
    @RezaulKarim-cq5ft Před měsícem

    Genius!

  • @Sumeet_100
    @Sumeet_100 Před 23 dny +1

    Understood !!

  • @suneelpadala1964
    @suneelpadala1964 Před 2 lety +1

    Excellent explanation bro

  • @shashijaiswal5014
    @shashijaiswal5014 Před rokem

    GREAT AND INSIGHTFUL VIDEO

  • @coding8000
    @coding8000 Před rokem +1

    Again @takeUforwad, just letting you know, again that's stuff you have done, is GOD's own work, thank you for from bottom of my heart, thanks !!!

  • @kushalsingh7789
    @kushalsingh7789 Před 5 měsíci

    Thanks man

  • @rpriyanka28
    @rpriyanka28 Před 2 měsíci +1

    he is the example of beauty with brains

  • @harshitatripathi6440
    @harshitatripathi6440 Před 11 měsíci

    best dp playlist on youtube

  • @AmanKumar-qz4jz
    @AmanKumar-qz4jz Před 5 měsíci

    god!!! of teaching dsa
    understood

  • @coderrr3353
    @coderrr3353 Před rokem +1

    This man is saviour. Thanks bhaiya ❤️

  • @_hulk748
    @_hulk748 Před rokem

    understood bhayia❤️🙏

  • @dnavas7719
    @dnavas7719 Před 2 lety +1

    beautifully explained thanks a lot!!

  • @sarveshamrute4982
    @sarveshamrute4982 Před 2 lety +6

    I solved with different tabulation approach (without shifting index) as below:
    int m=text1.length();
    int n=text2.length();
    int[][] dp = new int[m][n];
    int temp=0;
    for(int i=0; i

  • @girishbhargava6367
    @girishbhargava6367 Před 2 lety

    Striver, why can't we return INT_MIN , in the base case. Because if we return 0, it will be added to 1 and the resultant number will be considered for maximum. And even if it is not the maximum, it will be returned. Your explanation is very intuitive.

  • @user-ny1kv3xh4w
    @user-ny1kv3xh4w Před 11 měsíci

    Thank you Striver 😍

  • @jarvis3551
    @jarvis3551 Před 6 měsíci

    did it in 1st attempt without seeing the video, shifting index to right was new to me

  • @gunduboinadileep9523
    @gunduboinadileep9523 Před 7 měsíci

    understood!

  • @shababrabbani8085
    @shababrabbani8085 Před 2 lety

    You are a legend!

  • @arihantjammar8888
    @arihantjammar8888 Před 8 měsíci

    Understood 😊

  • @priyanshuchouhan9845
    @priyanshuchouhan9845 Před 9 měsíci +3

    who agrees that this dp series is one of the best on CZcams

  • @shineinusa
    @shineinusa Před 2 lety

    love this!

  • @vedxnt10
    @vedxnt10 Před měsícem

    simple space optimization technique : just 2,3 chanes
    instead of using 2 different vectors we can just change dimension of dp to [no of previous rows we wanred + 1][no of colum]
    int longestCommonSubsequence(string s1, string s2) {
    vectordp(2, vector(s2.size()+1, 0)); // changing dimension as per need
    for(int i=1; i

  • @alokvardhan
    @alokvardhan Před 5 měsíci

    good stuff

  • @rahulkakkar7241
    @rahulkakkar7241 Před 2 lety

    Explained Like a Dopamine Hit!

  • @ScienceSeekho
    @ScienceSeekho Před rokem

    Thanks learned new thing index shifting

  • @adebisisheriff159
    @adebisisheriff159 Před 6 měsíci

    Understood!!!

  • @aruna5869
    @aruna5869 Před 4 měsíci

    understood :)❤