<awangdev>72. Edit Distance_6.java
public int minDistance(String word1, String word2) {
		if (word1 == null && word2 != null) {
			return word2.length();
		} else if (word1 != null && word2 == null) {
			return word1.length();
		} else if (word1 == null && word2 == null) {
			return 0;
		}
		int[][] DP = new int[word1.length() + 1][word2.length() + 1];
		for (int i = 1; i <= word1.length(); i++) {
			DP[i][0] = i;
		}
		for (int j = 1; j <= word2.length(); j++) {
			DP[0][j] = j;
		}

		for (int i = 1; i <= word1.length(); i++) {
			for (int j = 1; j <= word2.length(); j++) {
				DP[i][j] = Math.min(Math.min(DP[i - 1][j] + 1, DP[i][j - 1] + 1), word1.charAt(i - 1) == word2.charAt(j - 1) ? DP[i - 1][j - 1] : DP[i - 1][j - 1] + 1);
			}
		}

		return DP[word1.length()][word2.length()];
    }
public int sample_funcname ( String var_1 , String var_2 ) {
  if ( var_1 == null && var_2 != null ) {
    return var_2 . length ( ) ;
  }
  else if ( var_1 != null && var_2 == null ) {
    return var_1 . length ( ) ;
  }
  else if ( var_1 == null && var_2 == null ) {
    return 0 ;
  }
  int [ ] [ ] var_7 = new int [ var_1 . length ( ) + 1 ] [ var_2 . length ( ) + 1 ] ;
  for ( int var_8 = 1 ;
  var_8 <= var_1 . length ( ) ;
  var_8 ++ ) {
    var_7 [ var_8 ] [ 0 ] = var_8 ;
  }
  for ( int var_9 = 1 ;
  var_9 <= var_2 . length ( ) ;
  var_9 ++ ) {
    var_7 [ 0 ] [ var_9 ] = var_9 ;
  }
  for ( int var_8 = 1 ;
  var_8 <= var_1 . length ( ) ;
  var_8 ++ ) {
    for ( int var_9 = 1 ;
    var_9 <= var_2 . length ( ) ;
    var_9 ++ ) {
      var_7 [ var_8 ] [ var_9 ] = Math . min ( Math . min ( var_7 [ var_8 - 1 ] [ var_9 ] + 1 , var_7 [ var_8 ] [ var_9 - 1 ] + 1 ) , var_1 . charAt ( var_8 - 1 ) == var_2 . charAt ( var_9 - 1 ) ? var_7 [ var_8 - 1 ] [ var_9 - 1 ] : var_7 [ var_8 - 1 ] [ var_9 - 1 ] + 1 ) ;
    }
  }
  return var_7 [ var_1 . length ( ) ] [ var_2 . length ( ) ] ;
}
