Edit Distance Between 2 Strings - The Levenshtein Distance ("Edit Distance" on LeetCode)

Edit Distance Between 2 Strings - The Levenshtein Distance ("Edit Distance" on LeetCode)

Back To Back SWE

6 лет назад

315,875 Просмотров

Ссылки и html тэги не поддерживаются


Комментарии:

@itjustworks4824
@itjustworks4824 - 12.04.2024 08:04

i dont get the operation it was very confusing

Ответить
@therockriders2759
@therockriders2759 - 24.04.2024 11:36

Thanks for the awesome explanation!

Ответить
@GoliHatami
@GoliHatami - 28.04.2024 14:30

tnxxx

Ответить
@kwazar6725
@kwazar6725 - 23.05.2024 00:09

Your explanation is very confusing. Ive seen much better examples

Ответить
@ramdamdam1402
@ramdamdam1402 - 23.05.2024 18:18

I'm sorry i'm probably dumb as f but i cannot figure out for the life of me why if the last characters match then the optimal transformation from A[0;i] to B[0;j] has the same number of steps as the transformation from A[0;i-1] to B[0;j-1]. Like formally why must that be true ? I understand even less when the last characters aren't the same

Ответить
@fertass7431
@fertass7431 - 26.05.2024 08:10

Les hoooooooooomes ❤️

Ответить
@halseywalker5015
@halseywalker5015 - 31.05.2024 16:49

Amazing

Ответить
@niccolomancini3801
@niccolomancini3801 - 10.06.2024 23:36

TY so much great explanation and I dont even speak english that well! Love from italy

Ответить
@jesca4855
@jesca4855 - 19.06.2024 10:46

ive left more confused than before. :(

Ответить
@markforbes6187
@markforbes6187 - 23.06.2024 19:54

Incredible video.

Ответить
@geertex
@geertex - 28.06.2024 14:31

Amazing explanation on dynamic programming! For this example it would be a really cool to add transposition which adds a nice extra special case.

Ответить
@Account-fi1cu
@Account-fi1cu - 04.07.2024 13:32

I am currently readin EPI book and have decided to cover almost all of it, and this question just threw me off the chair.
But you sir saved my ass, THANK YOU !
BTW I started reading this book thx to you, you mentioned it in one of ur videos.
Recursion and DP sections are significantly harder than what ive encountered so far in this book.

Did you go over these questions multiple times or just moved on to leetcode after ? In thinking of re-tracing my steps because these questions are so important, more than leetcode imo.

Ответить
@runsdeepmusic
@runsdeepmusic - 09.07.2024 08:04

Ben I want to learn to code after watching this video 👊🏽

Ответить
@IntegralDeLinha
@IntegralDeLinha - 12.07.2024 18:35

Thanks a lot! You made it really clearer! I couldn't see each cell as a subproblem before your video.

Ответить
@vinayakbiju
@vinayakbiju - 13.07.2024 00:43

I was initially confused midway, but going through the whole video cleared all my doubts. Thanks a lot

Ответить
@MyEthan1998
@MyEthan1998 - 15.07.2024 04:23

Hi there! I noticed a small mistake in your explanation. In JavaScript, substring(0, 0) returns an empty string "", not "b". The correct behavior is that substring(start, end) includes the character at the start index but excludes the character at the end index. For example, substring(0, 1) returns "b", substring(0, 2) returns "be", and so on. Just wanted to clarify in case anyone is following along. Thanks for the great content!

Ответить
@evermorecurious91
@evermorecurious91 - 03.08.2024 04:48

Thank you for this. I wanted to know if there is an equivalent edit distance for Javascript code?

Ответить
@EndToEndLearning-t2q
@EndToEndLearning-t2q - 22.08.2024 07:05

Wow this was great! Thanks a lot :)

Ответить
@micado6
@micado6 - 27.08.2024 00:13

I saw this algorithm in class and honestly couldn't follow it at all... I was hoping someone could explain it better on here, and you did!! thank you so much for this!

Ответить
@CodeWithZi
@CodeWithZi - 04.09.2024 13:57

Amazing!

Ответить
@Pedr0Diniz
@Pedr0Diniz - 16.09.2024 04:43

Thank you very much for this explanation.

I failed an interview that had this question and even though you said it's not about the pattern, the pattern did help me at least scrible the problem and get a feeling of it instead of being completely clueless.

Ответить
@TheOnly_Path
@TheOnly_Path - 18.09.2024 21:19

thanks alot

Ответить
@WIN_1306
@WIN_1306 - 29.09.2024 14:27

u got a new subscriber ,just keep posting such informative videos bruh

Ответить
@Edward-m7b
@Edward-m7b - 04.10.2024 12:33

I actually think there is a way easier approach if that is the only 3 rules we can have.
It just neccessary mean...
Edit distance = string size - Max(match in order)

Max(match in order) would mean...
Etc abcdefg is my aim, with aceg, the Max(match in order) would be 4.
In more complicated case like abcdefggfedcba against acfegfedcbd...
I think it is solvable with technique like min max in sub array
Which should make it easy to solve and potentially solvable in O(n^2)?

Ответить
@NalikaRu
@NalikaRu - 28.10.2024 23:30

really helpfull

Ответить
@kjk2973
@kjk2973 - 19.11.2024 21:36

i don't comment often but i have to say nice work, your explanation was very helpful

Ответить
@audunoklevik4435
@audunoklevik4435 - 09.12.2024 18:55

Very well explained, thank you! :D

Ответить
@audunoklevik4435
@audunoklevik4435 - 09.12.2024 19:00

Thank you, this was very good, thank you. I appreciate it.

Ответить
@arvpedro
@arvpedro - 10.12.2024 15:27

What gets me really depressed is when you open this on leetcode and it is written "medium"

Ответить
@Lamssatti1891
@Lamssatti1891 - 21.12.2024 01:29

Currently struggling with this problem. Tried DP but still struggling with the base case and the definition of the overall problem function to be honest. My only consolation is that I have ONLY spent a day on it and tried a few approaches, but nothing sticks. Thanks for putting this solution!

Ответить
@ismailmerteksi5704
@ismailmerteksi5704 - 12.01.2025 23:03

you are awesomeeeee!!!!!!

Ответить
@mostafaboostan9123
@mostafaboostan9123 - 24.01.2025 15:08

its so nice thanks

Ответить
@halilbakar7538
@halilbakar7538 - 28.01.2025 21:24

You are an excellent teacher!Thank you

Ответить
@sathwikreddy7347
@sathwikreddy7347 - 13.02.2025 06:19

Hey!! @BackToBackSWE, I am finding it difficult to understand exactly why (i-1,j-1) will be replace, (i-1,j) will be insert and (i,j-1) will be delete? Also confused on exactly why we added a column and row for empty string. This might be a wrong question, but trying to understand this so that I will get an intuition when I am solving similar question.

Ответить
@gabyp7530
@gabyp7530 - 18.02.2025 12:21

Can you compare it with money change and explain why you cannot solve it the same way?

Ответить
@baka6884
@baka6884 - 04.03.2025 05:22

This is the best video for edit distance

Ответить
@fkuciapa
@fkuciapa - 10.03.2025 16:55

Great explanation. I think that the square you show as "Our Key" is a actually incorrect...naturally incorrect from labelling viewpoint only as the logic of the algorithm is not flawed. Shouldn't the box say [replace, delete] in the first row and [insert, You are here] in the third row? I think it should

Ответить
@elikemaffram
@elikemaffram - 14.03.2025 01:11

Excellent explanation, no need to memorize patterns. Thank you

Ответить
@bettybunbun9664
@bettybunbun9664 - 17.03.2025 13:57

Leetcode only rates this medium difficulty, which is a bit of a joke to me. Its one of the only popular problems I wasnt able to solve on the fly and had to purposely look up an algorithm for.

Ответить
@YAELGONZALESGFX
@YAELGONZALESGFX - 25.03.2025 06:31

Thank you!!

Ответить
@zzzzzz8577
@zzzzzz8577 - 26.03.2025 07:51

IF HAD A TUTOR LIKE YOU I WOULD BE AT PLACES, BETTER PLACES

Ответить
@Ofri1717
@Ofri1717 - 26.03.2025 21:32

such a perfect explanation, the only one who made me understand it thank you so much!

Ответить
@yfzhangphonn
@yfzhangphonn - 18.04.2025 15:48

Greate explanation

Ответить
@dampdigits.69
@dampdigits.69 - 20.04.2025 09:31

fantastic explanation

Ответить
@milena8487
@milena8487 - 14.05.2025 23:57

Thank you!

Ответить
@doggie01031
@doggie01031 - 16.05.2025 23:58

Dude, you are amazing!!!!!

Ответить
@Curiousity22
@Curiousity22 - 20.05.2025 18:08

i have a confusion about how 0th row and 0th column is fixed using the below code. I understood the video explanation btw:

public static int EditDistance (String s1, String s2){
int m = s1.length();
int n = s2.length();

int[][] dp = new int[m+1][n+1];
for (int i = 0; i <=m; i++) {
dp[i][0] = i; //ISSUE: row wise filling---1st column fill-----insert----n length of s2
}
for (int j = 0; j <=n; j++) {
dp[0][j] = j; //ISSUE row filling----delete----m lenth of s1
}
for (int i = 1; i <=m ; i++) {
for (int j = 1; j <=n ; j++) {
if(s1.charAt(i-1) == s2.charAt(j-1)){
dp[i][j] = dp[i-1][j-1];
}
else{
dp[i][j] = Math.min(dp[i-1][j], Math.min(dp[i][j-1], dp[i-1][j-1])) + 1;
}
}
}
return dp[m][n];
}
}

Ответить
@tomelro6312
@tomelro6312 - 30.05.2025 04:19

Thank u very much but next time take it slow

Ответить