Problem:
Edit Distance (Levenshtein Distance)

Find the edit distance between given two words s1 and s2.

The disntace is the minimum number of single-character edits required to change one word into the other. The edits including the following operations:

insertion: Insert a character at a particular position.

deletion: Delete a character at a particular position.

substitution: Change the character at a particular position to a different character

Input

s1
s2

Two words s1 and s2 are given in the first line and the second line respectively. The words will consist of lower case characters.

Output

Print the edit distance in a line.

Constraints

1 ≤ length of s1 ≤ 1000

1 ≤ length of s2 ≤ 1000

Sample Input 1

acac
acm

Sample Output 1

2

Sample Input 2

icpc
icpc

Sample Output 2

0

Solution in C# (judge verdict: Accepted)

using static System.Math;
using System;

public class hello
{
    public static void Main()
    {
        var s1 = Console.ReadLine().Trim();
        var s2 = Console.ReadLine().Trim();
        var ans = goDP(s1, s2);
        Console.WriteLine(ans);
    }
    static int goDP(string s1, string s2)
    {
        var s1L = s1.Length;
        var s2L = s2.Length;
        var dp = new int[s2L + 1, s1L + 1];
        for (int i = 0; i < s2L + 1; i++) dp[i, 0] = i;
        for (int i = 0; i < s1L + 1; i++) dp[0, i] = i;
        for (int i = 1; i <= s2L; i++)
            for (int j = 1; j <= s1L; j++)
            {
                var c = s2[i - 1] == s1[j - 1] ? 0 : 1;
                dp[i, j] = Min(dp[i - 1, j - 1] + c, Min(dp[i, j - 1] + 1, dp[i - 1, j] + 1));
            }
        return dp[s2L, s1L];
    }
}