Minden Új

user:thomas létrehozva e felhasználó által

title:mygist gistek egyező címmel

filename:myfile.txt gistek melyek tartalmaznak fájlt egyező névvel

extension:yml gistek melyek tartalmaznak fájlt egyező kiterjesztéssel

language:go gistek melyek tartalmaznak fájlt egyező nyelvvel

topic:homelab gists with given topic

Regisztráció

Bejelentkezés

Minden Új Regisztráció Bejelentkezés

All gists matching topic interview

Újabbtól létrehozva
Utolsótól létrehozva
Újabbtól módosítva
Utolsótól módosítva

linkjobai / Edit Distance: A Dynamic Programming Walkthrough

0 Kedvelések
0 forkok
1 fájlok
Utoljára aktív 5 days ago
Interview prep notes
interview

Edit Distance: A Dynamic Programming Walkthrough

Edit Distance (LeetCode 72) asks for the minimum number of insertions, deletions and substitutions that turn one word into another. It's the textbook two-string DP and a good template for many others.

Define the state

dp[i][j] = minimum edits to turn the first i characters of a into the first j characters of b.

  • If a[i-1] == b[j-1]: dp[i][j] = dp[i-1][j-1].
  • Otherwise: 1 + min(dp[i-1][j] (delete), dp[i][j-1] (insert), dp[i-1][j-1] (replace)).
Újabb Régebbi

Ez az oldal Opengist alapú ⋅ Load: 28ms⋅

Magyar
Čeština Deutsch English Español Français Magyar Italiano 日本語 Polski Português Русский Türkçe Українська 中文 繁體中文