{ minDistance( word1, word2) { m word1.length(); n word2.length(); [][] dp [m ][n ]; ( i ; i m; i) { dp[i][] i; } ( i ; i n; i) { dp[][i] i; } ( i ; i m; i) { ( j ; j n; j) { (word1.charAt(i ) word2.charAt(j )) { dp[i][j] dp[i ][j ]; } { dp[i][j] Math.min(dp[i ][j] , dp[i][j ] ); } } } dp[m][n]; } }
不会,我可以学;落后,我可以追赶;跌倒,我可以站起来!