<awangdev>72. Edit Distance_2.java
public int minDistance(String word1, String word2) {
        if (word1 == null && word2 == null) return 0;
        if (word1 == null || word2 == null) return word1 == null ? word2.length() : word1.length();
        
        int m = word1.length();
        int n = word2.length();
        int[][] dp = new int[2][n + 1];
        
        for (int i = 0; i <= m; i++) {
            for (int j = 0; j <= n; j++) {
                if (i == 0) {
                    dp[i%2][j] = j;
                    continue;
                }
                if (j == 0) {
                    dp[i%2][j] = i;
                    continue;
                }
                if (word1.charAt(i - 1) == word2.charAt(j - 1)) {
                    dp[i%2][j] = dp[(i - 1)%2][j - 1];
                } else { 
                    dp[i%2][j] = Math.min(dp[(i - 1)%2][j - 1], Math.min(dp[i%2][j - 1], dp[(i - 1)%2][j])) + 1;
                }
            }
        }
        return dp[m%2][n];
    }
public int sample_funcname ( String var_1 , String var_2 ) {
  if ( var_1 == null && var_2 == null ) return 0 ;
  if ( var_1 == null || var_2 == null ) return var_1 == null ? var_2 . length ( ) : var_1 . length ( ) ;
  int var_6 = var_1 . length ( ) ;
  int var_7 = var_2 . length ( ) ;
  int [ ] [ ] var_10 = new int [ 2 ] [ var_7 + 1 ] ;
  for ( int var_11 = 0 ;
  var_11 <= var_6 ;
  var_11 ++ ) {
    for ( int var_12 = 0 ;
    var_12 <= var_7 ;
    var_12 ++ ) {
      if ( var_11 == 0 ) {
        var_10 [ var_11 % 2 ] [ var_12 ] = var_12 ;
        continue ;
      }
      if ( var_12 == 0 ) {
        var_10 [ var_11 % 2 ] [ var_12 ] = var_11 ;
        continue ;
      }
      if ( var_1 . charAt ( var_11 - 1 ) == var_2 . charAt ( var_12 - 1 ) ) {
        var_10 [ var_11 % 2 ] [ var_12 ] = var_10 [ ( var_11 - 1 ) % 2 ] [ var_12 - 1 ] ;
      }
      else {
        var_10 [ var_11 % 2 ] [ var_12 ] = Math . min ( var_10 [ ( var_11 - 1 ) % 2 ] [ var_12 - 1 ] , Math . min ( var_10 [ var_11 % 2 ] [ var_12 - 1 ] , var_10 [ ( var_11 - 1 ) % 2 ] [ var_12 ] ) ) + 1 ;
      }
    }
  }
  return var_10 [ var_6 % 2 ] [ var_7 ] ;
}
