Longest Common Subsequence

แชร์
ฝัง
  • เผยแพร่เมื่อ 10 ธ.ค. 2024

ความคิดเห็น • 556

  • @chenjus
    @chenjus 3 ปีที่แล้ว +80

    This is the clearest, complete, and most concise explanation of longest common subseq I've seen so far. Thank you so much!

    • @bhavyathakkar9194
      @bhavyathakkar9194 ปีที่แล้ว +3

      this is the most sarcastic comment on youtube

    • @woodylucas
      @woodylucas 5 หลายเดือนก่อน

      Say it again!

  • @nikkis8102
    @nikkis8102 ปีที่แล้ว +3

    I'm here 8 years later! I need him to go through all the Leetcode 75! 😃

  • @ketan4221
    @ketan4221 6 ปีที่แล้ว +120

    Tushar's favorite line - `Yes, we will use dynamic programming to solve this ;)`

    • @shashanksagarjha2807
      @shashanksagarjha2807 4 ปีที่แล้ว

      please check this playlist : th-cam.com/play/PLeF0b8iqbx4mogykbd82-HY9Y1-JS9MDr.html

    • @kurchak
      @kurchak 3 ปีที่แล้ว +5

      haha I always loved that too.

    • @amanrubey
      @amanrubey 2 ปีที่แล้ว

      😂😂😂❤

  • @dakshjay
    @dakshjay ปีที่แล้ว +1

    Just wanted to revisit Tushar's videos after completing my employment of 4 years at Google in the Bay Area. big thanks to you Tushar to help me with this and other challenging problems!

  • @GameKeppers
    @GameKeppers 8 ปีที่แล้ว +107

    reading wikipedia for ages...
    finnaly with your video i do understand the sequence so thank you very much:)
    greetings from Germany:)

    • @RagazzoKZ
      @RagazzoKZ 5 ปีที่แล้ว

      GameKeppers haha, same situation

    • @shashanksagarjha2807
      @shashanksagarjha2807 4 ปีที่แล้ว

      please check this playlist : th-cam.com/play/PLeF0b8iqbx4mogykbd82-HY9Y1-JS9MDr.html

  • @thesoftwareman
    @thesoftwareman ปีที่แล้ว +2

    I still come back to this video years later after tripling my SWE salary, priceless content

  • @amanrubey
    @amanrubey 2 ปีที่แล้ว +7

    The best part about his lectures are that the way he demonstrates things makes our brain automatically figure out why we are doing this and this is what no other channel on TH-cam provides.
    I'm really thankful to Tushar for making iterative dp my second nature 🙏🏼❤

  • @rma1563
    @rma1563 7 หลายเดือนก่อน

    took only 8 minutes to explain what most take 20+ minutes. And you did it great. cleared up everything. Thanks

  • @niqbal81
    @niqbal81 7 ปีที่แล้ว +5

    Love, how knowledgeable and clear as a teacher you are. Absolutely in debt. Much respect

  • @NehaJain1704
    @NehaJain1704 9 ปีที่แล้ว +35

    Nothing on the net has made DP more easier..thanks a ton!! :)

  • @ashdavv
    @ashdavv 8 ปีที่แล้ว

    Superb explanation .. If i am stuck in any problem then instead of google just finding your solution for the problem is the best thing.. Thanks ..

  • @satishchandra6623
    @satishchandra6623 3 ปีที่แล้ว +1

    The video that started my interest in dynamic programming. Seen this video 4 years ago in 2017 for the first time and with one example I got the whole idea about Dynamic programming. After that I'm able to solve most of the coding problems using Dynamic Programming approach.

  • @anshusharma11
    @anshusharma11 8 ปีที่แล้ว +2

    All your videos are just awesome. You explain every detail so clearly . I like that you don't rush the things.

  • @1234padrino
    @1234padrino 6 ปีที่แล้ว +12

    I wonder how my teachers can explain such simple algorithms in a way that noone understands it. I learned all algorithms from indian students. Thx, I love you man

  • @prashantganeshsamudrala626
    @prashantganeshsamudrala626 4 ปีที่แล้ว

    One of the Best explanations I have heard so far in coding

  • @nathant6010
    @nathant6010 3 ปีที่แล้ว +1

    Thank you Tushar. I am sure that no one have explained Dynamic Programming this simple and straightforward. Even we may not be able understand how the values are filled in the DP array dynamically in other explanations. Most of them are always very simple Fibonacci example or very high level. So, for anyone who would like to understand Dynamic Programming, your videos are the best.

  • @MagigeChacha
    @MagigeChacha 4 ปีที่แล้ว

    This is the best explanation for LCS problem so far. You are great bro.

  • @T1Oracle
    @T1Oracle 6 ปีที่แล้ว +1

    Learning how to use a matrix to solve these kinds of questions was a real break through for me. That visualization is better than seeing code, now I can write it any language easily.

  • @ameychavan70
    @ameychavan70 2 ปีที่แล้ว +1

    One of the best explanations I ever saw on this topic !!.... Thank you very much sir 😀 👏🏻👏🏻

  • @yanzheng2147
    @yanzheng2147 5 ปีที่แล้ว

    Supper clear! After watching your explanation, I am able to finish the code within 5 min! Thank you!

  • @aryankhare9393
    @aryankhare9393 4 ปีที่แล้ว

    Your way of teaching makes me visualise things and I really want to thank you for this.

  • @minhthinhhuynhle9103
    @minhthinhhuynhle9103 2 ปีที่แล้ว

    You are the best lecturer I currently found on TH-cam to teach hard problem using Advance Technique. No one else can eplain in short, precise & natural as you Tushar !!!
    > This will always be your punchline "The best we can do WITHOUT". And it's damn easy to understand in Natural Language rather than cold codes.

  • @GoldenSpud
    @GoldenSpud 6 ปีที่แล้ว

    You are an absolute champion, your answer and explanation was really clear great job.

  • @malinisai5297
    @malinisai5297 9 ปีที่แล้ว +21

    I learned most of the stuff from your videos, sir. It's quite helpful.Thank you so much.

  • @jaideepbommidi8611
    @jaideepbommidi8611 9 ปีที่แล้ว

    thank you very much I was able to understand everything.
    i was able to see how the already computed values were used for the calculation avoiding the redundancy, which is clearly a dynamic programming concept.
    thank you for such a wonderful video. Hope you help us more.

  • @RafaelNascimento-qo1jp
    @RafaelNascimento-qo1jp 2 ปีที่แล้ว

    BEST explanation on this topic so far!

  • @manhhungnguyen5661
    @manhhungnguyen5661 2 หลายเดือนก่อน

    This is the clearest explanation I've seen, thank u so much guy !!!! 🥰

  • @ashishgadre
    @ashishgadre 8 ปีที่แล้ว +5

    I think there needs to be more explanation on why there is a max used when the last char don't match. The reason is explained very well in the following section of the wiki page:
    en.wikipedia.org/wiki/Longest_common_subsequence_problem#Second_property
    Suppose that the two sequences X and Y do not end in the same symbol. Then the LCS of X and Y is the longer of the two sequences LCS(Xn,Ym-1) and LCS(Xn-1,Ym).
    To understand this property, consider the two following sequences :
    sequence X: ABCDEFG (n elements)
    sequence Y: BCDGK (m elements)
    The LCS of these two sequences either ends with a G (the last element of sequence X) or does not.
    Case 1: the LCS ends with a G
    Then it cannot end with a K. Thus it does not hurt to remove the K from sequence Y: if K were in the LCS, it would be its last character; as a consequence K is not in the LCS. We can then write: LCS(Xn,Ym) = LCS(Xn, Ym-1).
    Case 2: the LCS does not end with a G
    Then it does not hurt to remove the G from the sequence X (for the same reason as above). And then we can write: LCS(Xn,Ym) = LCS(Xn-1, Ym).
    In any case, the LCS we are looking for is one of LCS(Xn, Ym-1) or LCS(Xn-1, Ym). Those two last LCS are both common subsequences to X and Y. LCS(X,Y) is the longest. Thus its value is the longest sequence of LCS(Xn, Ym-1) and LCS(Xn-1, Ym).

  • @gauravkumarsingh3234
    @gauravkumarsingh3234 7 ปีที่แล้ว

    I must say your videos are very helpful... I consider only your videos for my Data structure and algorithms exams preparation..

  • @deepTh00ught
    @deepTh00ught 4 ปีที่แล้ว +1

    Tushar you are such a good human, thank you a lot

  • @accelator007
    @accelator007 4 ปีที่แล้ว

    By far the best video on this topic.

  • @TheOscarJB
    @TheOscarJB 6 ปีที่แล้ว

    once again, thank you for your teaching, it is easier to understand, compared to my professor's teaching

  • @yvestuyishime5209
    @yvestuyishime5209 7 ปีที่แล้ว

    well, i don't know how i could pass quizzes without your videos :( I've been using your videos for most of algorithms and they are ease to understand and not time consuming compared to the time i could spend reading the book and sometime don't even understand the pseudo-code itself. THANK YOU, THANK YOU AND THANK YOU ONCE MORE.

  • @OdiyaS
    @OdiyaS 8 ปีที่แล้ว +1

    great video! saved me hours of trying to understand the slideshow from class!

  • @deepakbisht7764
    @deepakbisht7764 8 ปีที่แล้ว +16

    THKS man you just save my Semester

  • @aggreym.muhebwa7077
    @aggreym.muhebwa7077 7 ปีที่แล้ว

    +1 for explaining DP in such an easy way. Thanks alot

  • @javadoctor101
    @javadoctor101 7 ปีที่แล้ว

    To everyone who is saying that he is NOT explaining the reasoning, please listen closely and pause at 4:50. He explains at 4:50 why we add 1+ diagonal when chars are same and why we do max(left,top) when they are different.

  • @ericren4909
    @ericren4909 9 ปีที่แล้ว +2

    Thanks I'm making progress on my interview skills. Awesome tutorials.

  • @shingo9302
    @shingo9302 5 ปีที่แล้ว +3

    Feels so good to finally understand this, thank you!

  • @khalednaami2
    @khalednaami2 6 ปีที่แล้ว

    After searching LCS a lot on the web, finally I found an easy explanation. Thanks a lot.

  • @satang500
    @satang500 9 ปีที่แล้ว +2

    I've been looking at lots of lecture notes, tutorials and videos in the Internet to understand DP, but couldn't clearly understand until I watched your video. Your approach of DP is the best I've ever seen and now I'm confident in DP. :)

  • @robertsun5529
    @robertsun5529 8 ปีที่แล้ว

    Very clear little tutorial! Nice job and thanks!!

  • @manantank
    @manantank 7 ปีที่แล้ว +1

    i have passed the algorithm subject just by watching your videos... thanks a lot !!

  • @ruthsalinas2613
    @ruthsalinas2613 9 ปีที่แล้ว

    THANK YOU! You saved me! No one on the net has ever explained DP well but you. Keep it up :)

  • @vikramadityakukreja4795
    @vikramadityakukreja4795 9 ปีที่แล้ว +7

    Nicely explained and easy to understand . Thanks a lot!

  • @prateekyadav1109
    @prateekyadav1109 9 ปีที่แล้ว

    your videos are really helpful and you are doing a noble job.

  • @alifhasnain3200
    @alifhasnain3200 6 ปีที่แล้ว

    You make every topic very easy to understand. Thanks. :)

  • @0diepus
    @0diepus 7 ปีที่แล้ว

    Holy mollie! I finally got it!!!! Thanks for the time you put into this.

  • @aditijain515
    @aditijain515 9 ปีที่แล้ว +18

    You have explained all DP problems very well...thanks a ton :)

  • @rudolferemyan8133
    @rudolferemyan8133 8 ปีที่แล้ว +157

    Thnx a lot... it's so easy to understand and implement and not try to memorize a code When you have Cool teacher like you)) One more time THNX))

    • @akshaychatterjee3328
      @akshaychatterjee3328 7 ปีที่แล้ว +19

      do u memorize code generally?

    • @cantwaittowatch
      @cantwaittowatch 7 ปีที่แล้ว +2

      its our great teachers in colleges who passed this wealth of memorization knowledge with out giving an explanation like this which makes algorithms difficult to learn. I'm not surprised to hear these comments. I'm glad Tushar is doing such a wonderful job here. Kudos to him!!

    • @avinashtripathi4159
      @avinashtripathi4159 7 ปีที่แล้ว

      Rudolf Eremyan is this algorithm o(n)?

    • @miltonkumar3655
      @miltonkumar3655 7 ปีที่แล้ว

      O(nm)

    • @avinashtripathi4159
      @avinashtripathi4159 7 ปีที่แล้ว

      MILTON KUMAR exactly! And that is not linear time

  • @varunkumar3594
    @varunkumar3594 8 ปีที่แล้ว

    These videos are enjoyable, you rock man

  • @mehdiamiri5418
    @mehdiamiri5418 10 วันที่ผ่านมา

    such a clear explanation. you nailed it

  • @extremecreators
    @extremecreators 6 ปีที่แล้ว +1

    2018 Anyone? This is one of the most elegant DP with backtracking table algorithms.

  • @jayeshkawli
    @jayeshkawli 5 ปีที่แล้ว

    Amazing video. Would have taken me an entire day had I gone through online sources. This cleared all the things in less than 10 minutes. Thank you so much!!

  • @johnbrown903
    @johnbrown903 6 ปีที่แล้ว

    ive learned alot from your vids of dynamic programming. Thanks man

  • @Aldrasio
    @Aldrasio 6 ปีที่แล้ว

    Great explanation, this makes dynamic programming much easier to understand.

  • @deansonnier1167
    @deansonnier1167 6 ปีที่แล้ว +1

    What a fantastic lesson! Thank you, Tushar.

  • @suryamp12
    @suryamp12 9 ปีที่แล้ว

    Dude, I really like your videos. Super helpful during prep. I hope you're having fun at your workplace but you should consider doing this fulltime ;)

  • @66saly
    @66saly 7 ปีที่แล้ว +2

    Perfect tutorial! You deserve hundred of likes for saving my time 👍🏼

  • @harinijeyaraman8789
    @harinijeyaraman8789 4 ปีที่แล้ว

    Love your videos Tushar ! Thanks ! really appreciate your efforts

  • @serhiypidkuyko4206
    @serhiypidkuyko4206 6 ปีที่แล้ว +1

    Hi Tushar
    Thank you for your video
    As for the code: you don't need to create the matrix
    Here is the code in python:
    #
    def longest_common_subseq_(s,t):
    n=len(s)
    result=[0]*(n+1)
    for x in t:
    row=[0]*(n+1)
    for j in range(n):
    if x==s[j]:
    row[j+1]=result[j]+1
    else:
    row[j+1]=max(row[j],result[j+1])
    result=row
    subseq=''
    indices=[]
    for j in range(n):
    if result[j]

  • @dailydestress6189
    @dailydestress6189 3 ปีที่แล้ว

    Explained so simply. Thanks a lot.

  • @Firecloak
    @Firecloak 4 ปีที่แล้ว

    clear, short explanation. Thank you so much!

  • @jesusantoniososaherrera2217
    @jesusantoniososaherrera2217 8 ปีที่แล้ว

    Very clear and easy to understand.
    Cheers !!!

  • @subhashreesahu692
    @subhashreesahu692 7 หลายเดือนก่อน

    this is the one who helped me thank you sir

  • @MarvinsRoom_
    @MarvinsRoom_ 4 ปีที่แล้ว +1

    Good tutorial. Very articulate and clear 🙏

  • @dimitrisdimitriou6969
    @dimitrisdimitriou6969 6 ปีที่แล้ว

    The best explanation on LCS

  • @PradeepKumar-ue2ct
    @PradeepKumar-ue2ct 8 ปีที่แล้ว

    Very nice...!! Got it in 8min !! Wonderful work dude!! :)

  • @BrianOndieki9
    @BrianOndieki9 9 ปีที่แล้ว

    Thank you, you really make DP very easy to understand

  • @ParagAwadhiya
    @ParagAwadhiya 6 ปีที่แล้ว

    Thanks Tushar, you've made it so simple to understand.

  • @gaiusjuliuscaesar9296
    @gaiusjuliuscaesar9296 2 ปีที่แล้ว

    Great explanation of the process, thanks!

  • @pdppradeep
    @pdppradeep 8 ปีที่แล้ว

    You made it look some simple tushar!, you are a great teacher., thanks.

  • @miladnaderi4169
    @miladnaderi4169 9 ปีที่แล้ว

    thank you very much you helped me pass algorithms man

  • @camccorm
    @camccorm 8 ปีที่แล้ว +4

    Thank you so much for this video, you explained it very well! Much appreciated!

  • @thaneshwarsahu1633
    @thaneshwarsahu1633 7 ปีที่แล้ว +1

    yes sir , your explanation process is very good and I'm very easily understand this tricky concepts
    thank you very much sir

  • @dighechinmayt
    @dighechinmayt 7 ปีที่แล้ว

    Thanks Tushar, your video lectures help me a lot in studies.So much clearly explained! :)

  • @riceboom360
    @riceboom360 4 ปีที่แล้ว

    the best explanation ever, thank you

  • @Jaqen_Hghar
    @Jaqen_Hghar 7 ปีที่แล้ว

    Thanks a lot, your videos are really very nice and clear. Helping me a lot in my Algorithm course.....

  • @cook9256
    @cook9256 6 ปีที่แล้ว

    It is so clear now after watched this video. Thanks!!

  • @partha95123
    @partha95123 8 ปีที่แล้ว

    Very good tutorials. Thanks a lot Tushar for the video.

  • @WassupCarlton
    @WassupCarlton 7 หลายเดือนก่อน +1

    good stuff my guy. question: do we NEED the row and column that's full of zeros?

  • @Mankind5490
    @Mankind5490 8 ปีที่แล้ว

    Excellent Explanation. Thank you Tushar!

  • @arun6849
    @arun6849 9 ปีที่แล้ว

    you are too good in explaining problems :)

    • @arun6849
      @arun6849 9 ปีที่แล้ว

      I meant both :). Too good. Keep up the good work.

  • @kalpkumudkumar8163
    @kalpkumudkumar8163 6 ปีที่แล้ว

    nailed bro .... thanks I was struggling with this problem .. now it is much clear .

  • @otalgebra4436
    @otalgebra4436 3 ปีที่แล้ว

    Just remember that once you have a match you cannot match anymore down the row.

  • @nobody_cares256
    @nobody_cares256 11 หลายเดือนก่อน

    thanks a lot, that's the explanation I was looking for

  • @synycboom
    @synycboom 9 ปีที่แล้ว +1

    Thank you guy. I've just understood how to solve this problem from you :)

  • @hamzasaeedsippal
    @hamzasaeedsippal 6 ปีที่แล้ว

    thanks. simply and clearly defined.

  • @irynasherepot9882
    @irynasherepot9882 4 ปีที่แล้ว

    Thank you Tushar, your tutorial are great and helped me a lot!

  • @shivamrohilla9379
    @shivamrohilla9379 6 ปีที่แล้ว

    thanks a lot bro
    keep making these types videos
    very helpful in clearing concepts

  • @muhammedalidilekci4585
    @muhammedalidilekci4585 6 ปีที่แล้ว

    this video has really helped me out for my project. Really thank you. You made it so easy that even a 12yrs old boy would understand this after watching video. Really really thank you again.

  • @chandruscm
    @chandruscm 9 ปีที่แล้ว

    Clear and to the point! Thanks a ton!

  • @yovomanolov96
    @yovomanolov96 7 ปีที่แล้ว

    Thank you very much , keep "walking" with the great content !

  • @shanta32220
    @shanta32220 8 ปีที่แล้ว

    thank you so much! I wanted to solve a problem related to this but even seeing the solutions i had no idea what they were doing until i saw your explanation!. will make sure to check more videos of yours. ^_^

  • @guieguima
    @guieguima 5 ปีที่แล้ว

    Thank you once again for the explanation! You really are a life-saver!

  • @punjabitadka1594
    @punjabitadka1594 3 ปีที่แล้ว

    had to watch at 0.75x speed bt understood completely thank you man

  • @sureshchowta
    @sureshchowta 8 ปีที่แล้ว

    Thank you for these videos on Dynamic Programming...

  • @omkarpanhalkar6837
    @omkarpanhalkar6837 8 ปีที่แล้ว +1

    Hi Tushar thanks for the videos.. I am going through lot of your material lately...
    public int lcsDynamic(char str1[],char str2[]){
    int temp[][] = new int[str1.length + 1][str2.length + 1];
    int max = 0;
    for(int i=1; i < temp.length; i++){
    for(int j=1; j < temp[i].length; j++){
    I believe max cases in for loop need to be "i

  • @DeepakSingh-uf5vv
    @DeepakSingh-uf5vv 7 ปีที่แล้ว

    thankyou so much sir ,cant explain the happiness in words

  • @hrishikeshwaikar251
    @hrishikeshwaikar251 8 ปีที่แล้ว

    Very well explained . Thanks for simplicity!