Home
Log in
DescriptionSubmissionsSolution
DescriptionSubmissionsSolution
Loading...

Log in to run or submit

word1 =
word2 =

Codey

Practise coding problems, test your solutions and track your progress.

Explore

  • Problems
  • About
  • Contact

Legal

  • Privacy Policy
  • Terms of Use

© 2026 Codey. Personal learning project.

Solution
Updated: 2026-02-23

Idea

Classic Levenshtein distance DP.

Approach

dp[i][j] = min edits to convert word1[:i] to word2[:j]. If last chars equal: dp[i-1][j-1]. Else: 1 + min(replace, delete, insert). Use 1D rolling DP.

Code
Loading...
Complexity
Time: O(mn)
Space: O(min(m,n))
Solution
Updated: 2026-02-23

Idea

Classic Levenshtein distance DP.

Approach

dp[i][j] = min edits to convert word1[:i] to word2[:j]. If last chars equal: dp[i-1][j-1]. Else: 1 + min(replace, delete, insert). Use 1D rolling DP.

Code
Loading...
Complexity
Time: O(mn)
Space: O(min(m,n))