Longest Repeating Subsequence | Dynamic Programming | LCS

Поділитися
Вставка
  • Опубліковано 5 жов 2024
  • This video explains a very important dynamic programming interview problem which is to find the longest repeating subsequence length as well as string.This problem is a variation of the longest common subsequence. I have first explained the problem statement and then I have shown how this problem is similar to Longest Common Subsequence.I have used simple examples and have also shown the dry run for finding both LRS and LRS string.CODE LINK is present below as usual. If you find any difficulty or have any query then do COMMENT below. PLEASE help our channel by SUBSCRIBING and LIKE our video if you found it helpful...CYA :)
    ========================================================================
    Join this channel to get access to perks:
    / @techdose4u
    INSTAGRAM : / surya.pratap.k
    SUPPORT OUR WORK: / techdose
    LinkedIn: / surya-pratap-kahar-47b...
    WEBSITE: techdose.co.in/
    TELEGRAM Channel LINK: t.me/codewithT...
    TELEGRAM Group LINK: t.me/joinchat/...
    =======================================================================
    USEFUL VIDEOS:-
    Longest Common Subsequence: • Longest common subsequ...
    Longest Common Substring: • Longest common substri...
    Uncrossed Lines: • Uncrossed Lines | Dyna...
    #dp #lcs #lrs

КОМЕНТАРІ • 48

  • @theghostwhowalk
    @theghostwhowalk 3 роки тому +28

    Just amazing. I so much like them that even after 2 FANG offers I am glued to these. Again all thanks to you for coding Qs. Kudos to also the fact while people are busy making paid sites, you are making this high quality content free to all aspirants via UA-cam.

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

      Thanks for supporting :)

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

      Please ping me on LinkedIn

  • @VinothiniAnabayan
    @VinothiniAnabayan 3 роки тому +5

    Crystal clear explanation, the first channel i prefer after seeing the problem statement. keep making videos

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

    in else if condition: not s[i][j] its s[i-1][j-1];
    if we consider loop i=0 &j=0 then dp[0][j] &dp[i][0] not valid or if we consider loop i=1& j=1 then we miss 0th charecter of string.

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

    Came here after watching Aditya Verma's video ... best explanation!

  • @Aryansingh-fk7hy
    @Aryansingh-fk7hy 3 роки тому +3

    Sir, at 6:03, the string AXXX, why didn't you also consider x(3) -string-1 combined with x(1), string-2, they both x at 3rd index of string 1 and x at 1th index of string-2 are not overlapping by indexes.

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

    It should be s1[i-1] == s2[j-1] in else if condition of the code which you have explained.

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

      That will be correct if he had added 1 to the length of row and col of the table

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

    Can we return the string value of LCS in same way as you did in the last part of the video ?

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

    14:10 ==>> This is the tablular form where LCS of the 2 strings at a given index(2d) are not at the same index in original string

  • @Balaji-kg3ri
    @Balaji-kg3ri 3 роки тому +1

    The explanation is so clean❤️

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

    Nice video request you to please advise which software you using for display

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

    Wow Really Nice Explanations !!

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

    Awesome video!

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

    Your videos are awesome! Keep producing these amazing videos.

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

    Nice explanation

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

    I dont understand the example of 'AXXX' .here the longest repeating subsequence is XX but no matter which index of X you take when repeating 'XX' one index will be common...please explain

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

      look at the constraint,corresponding characters should have different indices in the main string

    • @27-Joshna
      @27-Joshna 9 місяців тому

      Thank you my doubt got cleared ..@@bharathkumar5870

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

    you are great sir!

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

    amazing vedio

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

    Initialization Condition is done according to LCS/LRS logic ?... i.e., filling 1st row & 1st column of DP Table?

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

    A higher time complex approach

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

    Cleanest❤

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

    How to declare lsc[][] 2d array in when we are returning string ? (I.e in second case )

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

      Did you try vector of vector of string ?

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

    what about aaa, isisi

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

    can we use the same method for forming lcs as you shown in this video

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

    Hi Tech Dose, is this a leetcode problem?

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

    I EXPECT A REPLY ON THIS
    length is coming wrong in one of mine testcases ,n=157 expected =45,output=44
    gjlapopkvxfgvicetcmkbljopgtqvvhbgsdvivhesnkqxmwrqidrvmhlubbryktheyentmrobdeyqcrgluaiihveixwjjrqopubjguxhxdipfzwswybgfylqvjzharvrlyauuzdrcnjkphclffrkeecbpdipu

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

      Hard to check this for me

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

    Please at least do a code walkthrough in the end🙏

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

      This was LCS so dint do it.