DP 30. Minimum Insertions/Deletions to Convert String A to String B

Sdílet
Vložit
  • čas přidán 6. 09. 2024
  • Lecture Notes/C++/Java Codes: takeuforward.o...
    Problem Link: bit.ly/3pya8CP
    Pre-req for this Series: • Re 1. Introduction to ...
    a
    Make sure to join our telegram group for discussions: linktr.ee/take...
    Full Playlist: • Striver's Dynamic Prog...
    In this video, we solve the minimum insertions and deletions to convert a String A to String B. Please watch the LCS video before doing this.
    If you have not yet checked our SDE sheet, you should definitely do it: takeuforward.o...
    You can also get in touch with me at my social handles: linktr.ee/take...

Komentáře • 360

  • @kushalchakraborty6970
    @kushalchakraborty6970 Před 2 lety +282

    Moral of the story : DP on strings = learn LCS by heart ,❤️ Kudos to your efforts

  • @shridharsarraf2188
    @shridharsarraf2188 Před 2 lety +75

    that feeling of self-improvement when you don't even watch the whole video, and just in between i thought of the solution and wrote it by my own. Amazingly explained striver bhaiya

  • @nagasrikuncharapu3736
    @nagasrikuncharapu3736 Před 7 měsíci +16

    was able to solve it without watching the video , but still watched it incase I miss anything important. Thanks a lot

  • @johncenakiwi
    @johncenakiwi Před 2 lety +31

    I saw the length of the video and got the hint to solve it with the ongoing pattern (LCS). Coded in under 3 minutes!! Thanks Striver. I think I am really building the intuition for DP problems. I have been with the series from the beginning and I can proudly say that I can solve every single problem in this series till now with ease. I prefer solving using Recursion+Memo but I am also able to write the Tabulation solution for most of the problems. Thanks a tonne brother!!

    • @aniketghosh2001
      @aniketghosh2001 Před 2 lety +8

      I read your comment, got motivated, paused the video and thought for a bit, and I also solved the problem all by myself without watching the complete video, now I'm also developing confidence in solving DP problems ^_^

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

      Same in my case , i also saw the length of video then i understand it must be solved by LCS then i solved it without watching the video😃😃

    • @analyticswithjaspreet
      @analyticswithjaspreet Před 2 lety

      btw writing till memo during interview will not work ? means test cases surely gonna fail ? @Rishabh

  • @amitkulkarni9682
    @amitkulkarni9682 Před 4 měsíci +3

    Solved this after watching 1:49 minutes. There is no better person for DSA than Striver. Huge respect to you 💯

  • @chitranshjain5075
    @chitranshjain5075 Před 2 lety +21

    Woah! LCS proved to be a really important topic and thanks to you, I've understood it very clearly!

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

    I Solved without watching, thank you so much striver for providing this wonderful content.

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

    Understood, thanks for making these things like "halwa". At the same time huge respect for the amount of hardwork you must have put in to come up with these amazing (easy) logical explanations! Cheers to you buddy!

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

    You are always providing awesome content for any level of coder noob to pro can easily understood the concept and logic.Thank you sir.

  • @ganeshkamath89
    @ganeshkamath89 Před 2 lety +7

    Thanks Striver. Understood.
    I don't know if this intuition will occur to candidates in a real interview.

  • @DeepakVerma-iitbhu
    @DeepakVerma-iitbhu Před 2 lety +8

    This is the first DP on strings question I did by myself ❤️ Thank you so much Striver 🙇🙏

  • @anshumaan1024
    @anshumaan1024 Před rokem +2

    same question @leetcode - "Delete Operation for Two Strings"

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

    Funny story: I got this question during an interview for a startup and I had no idea it was a dp question, i just did simple hashing for both strings and compared and the interviewer said it wouldn't work but didn't seem to know in what case exactly. He couldn't prove it, so we ran it on their system and they must have had weak test cases because the code came as 100% correct and the interviewer was super impressed and told me that I had taught him a new way to solve the question and I legit got in. I didn't accept because I had one other option but still. (Hashing for this question is completely wrong btw, for anyone wondering, it ignores a very important part of the question which is the order of the letters. You can try the leetcode question and do hashing, you'll see it runs about 900 testcases and fails the rest)

  • @SumitSharma-do2uc
    @SumitSharma-do2uc Před 2 lety +4

    shi m ye subsequence or palidrome k question m kr para hun? ......bachpan m to inke nam se hi dar lgta tha

  • @studygainer5482
    @studygainer5482 Před 4 měsíci +1

    osssm yaaar striver sir love u khud se dp solution hone lga h ab

  • @harshal018
    @harshal018 Před rokem +1

    Best Playlist on DP

  • @utkarshsingh2747
    @utkarshsingh2747 Před rokem +3

    Your previous video gave a thought of using the earlier concept as an application for other questions, just few changes & boom! ❤Your content is just awesome!(Topic - LCS & it's Application XD...!)😆

  • @himanshu_047
    @himanshu_047 Před 11 dny

    Hard label dekh ke hamesa fatt jati thi, now solved this problem without watching the video❤ thanks to you

  • @jonathanjones6657
    @jonathanjones6657 Před 2 lety +3

    You’re strong.

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

    Thanks a lot sir! I used to dread such questions, now I am really enjoying solving 'em.

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

    You should also put "Edit path" in title since its popular with that name. Will help in YT recommendation.

    • @puneetsharma7117
      @puneetsharma7117 Před 2 lety +7

      This is not Edit Distance problem but very similar to it. You can replace characters in Edit distance whereas only deletion and insertion is possible is this one.

  • @shrikantsahu7115
    @shrikantsahu7115 Před 2 lety +3

    Thanks a lot Striver, I always wondered how to solve DP questions, but now I am able to solve and think on my own!!

  • @user-zy5di2ys6l
    @user-zy5di2ys6l Před 4 měsíci

    Without even seeing the whole video I got the logic and solved it in leetcode in one go. All thanks to striver. You are GOD of DSA.

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

    DID THIS QUE BY MYSELF , THANK YOU STRIVER

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

    Amazing solution...I wrote tabulated code without watching the solution...Thank you, LCS and Striver💝💝 #UNDERSTOOD

  • @rishabhshairy972
    @rishabhshairy972 Před 22 dny

    Solved even before watching this video. LCS is key ❤❤

  • @YashveerGahlot-t6b
    @YashveerGahlot-t6b Před 16 dny

    sir !! your approches are so good and optimal
    thank you sir!!

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

    understood

  • @sangeetasharma8574
    @sangeetasharma8574 Před rokem

    typing understood has become a formality , cause we r already getting ideas to solve DP problems. Thanks striver.

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

    Understood, Thank You so much!!

  • @lakshsinghania
    @lakshsinghania Před rokem +1

    the intuition just striked by it self without watching the video
    thnx striver!

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

    Adding to this :
    Delete Operation for Two Strings will also be the same solution❤.

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

    Understood

  • @ratinderpalsingh5909
    @ratinderpalsingh5909 Před 2 lety +3

    Understood, sir. Thank you very much.

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

    it was quite similar to the previous question, solved it in just 5min :)

  • @shubhankar_naik
    @shubhankar_naik Před rokem

    First time I solved a question without looking at your approach thanks for making LCS easy

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

    Understood Raj bro...such a easy and nice explaination

  • @kbizzy111
    @kbizzy111 Před 27 dny

    Watched every video, great series

  • @arpnasjs9825
    @arpnasjs9825 Před rokem

    Solved before watcing...All thanks to u bhaiya....#UNDERSTOOD!

  • @xavier4107
    @xavier4107 Před rokem

    We can do this with hashing also...
    Time complexity is O(S1 length + s2 length). No recursion...

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

    Solved it on my own
    thanks to striver
    #UNDERSTOOD

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

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

  • @udatyadeb101
    @udatyadeb101 Před rokem

    yay! did it by myself just reading the question.

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

    UNDERSTOOD!!!🔥🔥🔥🔥🔥🔥

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

    "UNDERSTOOD BHAIYA!!"

  • @codewithom11
    @codewithom11 Před rokem

    Previous two questions in dp series, solved by myself . Yup 😎😎

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

    Mind blowing before watching the video i was able to do this becuz i have watched all the previous videos and i have understood very well this is insane and thank you striver.❤❤❤❤

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

    Al always "understood"

  • @aparna5364
    @aparna5364 Před 2 lety +4

    if we are given different costs for insertions ,deletions and replace operations.Does anyone know how to minimise the cost to convert one string to another

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

      yeah, instead of doing "1 + helper()" in recursive relations, return "cost + helper()"

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

    understood bhaiya

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

    Amazing sir!!
    Understood. You are awesome!!

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

    LCS is amazing !!!

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

    thank you bhaiya for this amaing series

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

    Understood!!!!

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

    Understood!!!...

  • @ishangujarathi10
    @ishangujarathi10 Před rokem

    Understood Completely!!!

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

    Understood !

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

    Understood, thank you so so much, solved it on my own completely

  • @harshitjaiswal9439
    @harshitjaiswal9439 Před rokem

    Understood Striver! Thank you for such fantastic explanation!

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

    Understood ❤

  • @rishabhgupta9846
    @rishabhgupta9846 Před rokem

    understood,solved by myself.If we closely analyse the test cases we know it is n+m-2*LCS

  • @santanu29
    @santanu29 Před rokem

    I figured it out on my own. Your videos are awesome.

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

    Understood 🙂🙂💚

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

    Understood, had to take a day off yesterday because of LC contest and was a little tired of nonstop dp haha! Back on the dp so full throttle

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

    Without watching this, I was able to solve. 🙌

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

    Thanks sooooooooooooooooooooooooooooooo much striver. This completely amazing!!!

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

    Understood...😊

  • @Anonymous_Coder
    @Anonymous_Coder Před rokem

    Did this problem on myself, thanks bhaiya for making such an amazing content.

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

    LCS is King !!

  • @GopalKumar-py2cf
    @GopalKumar-py2cf Před rokem

    this is the 1st question I solved lcs of string

  • @saitejakura
    @saitejakura Před rokem

    mind blowing before watching the video i was able to do this becuz i have watched all the previous videos and i have understood very well this is insane and thank you striver.

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

    This was incredible. I don't understand the theory behind why it works( how you know this is the min there is probably a proof somewhere). But I guess you don't need too for some probrlems.

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

    understood sir

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

    Amazing 🤩😄 . Indescribable 💯💯🚀

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

    Thank You
    Understood!!!

  • @vipulchaudhary_js
    @vipulchaudhary_js Před rokem

    solved without watching video, Thank You so much Striver bhaiya

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

    Understood 💯💯💯

  • @DeepakSingh-wd2rb
    @DeepakSingh-wd2rb Před 2 lety +1

    UNDERSTOOD

  • @ronakslibrary8635
    @ronakslibrary8635 Před rokem

    US You r teaching is OP

  • @KAAO-rb9lh
    @KAAO-rb9lh Před 25 dny

    great playlist

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

    Can anyone tell me what should we do if the question ask for "REPLACE" , "DELETE" and "INSERT"??

    • @softwarefoodiee
      @softwarefoodiee Před rokem

      There is nothing to replace actually here because if it exists in both the strings then it will be considered in the longest common subsequence.

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

    Understood :)

  • @Coder-zz1tn
    @Coder-zz1tn Před 4 měsíci +1

    "THANKS BRO FOR KEEPING IT SHORT"

  • @kathanvakharia
    @kathanvakharia Před rokem

    Understood...Completed 30/56

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

    Understood kaka!

  • @fmkhandwala39
    @fmkhandwala39 Před rokem

    str.size()+ptr.size()-2*lcs(str,ptr)

  • @shreyasnagabhushan4918

    understood bro, I didn't even realise that so many questions could be solved by just knowing LCS .

  • @Hello-ro6hr
    @Hello-ro6hr Před 2 lety +1

    UNDERSTOOD ...

  • @meme_eternity
    @meme_eternity Před rokem

    Solved it just by listening to question OP Striver ❤

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

    Understood. Thankyou Sir

  • @warriorgaming9509
    @warriorgaming9509 Před rokem

    Amazing Series Bhaiya Loving it :))))))))

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

    Understood SIr

  • @aryankumar3018
    @aryankumar3018 Před 6 dny

    Understoood

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

    understood❤❤

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

    understood:)😀😀

  • @radharamamohanakunnattur3035

    Understood!! awesome explanations!!

  • @kumarpurushottam632
    @kumarpurushottam632 Před rokem

    Understood Thank You Striver 😇

  • @HimanshuGupta-ni3pk
    @HimanshuGupta-ni3pk Před rokem

    I love you man for making dp so easy 😂

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

    Understood.

  • @cminor9037
    @cminor9037 Před rokem

    at 2:00 i was able to create logic that answer would be just no of character except the number of character in lcs
    "US"