public static int minDistance(String word1, String word2) {
		char[] s1=word1.toCharArray(), s2=word2.toCharArray();
		int m=s1.length, n=s2.length;
		int[][]t=new int[m+1][n+1];
		for (int i=1;i<=m;++i)
			t[i][0]=i;
		for (int j=1;j<=n;++j)
			t[0][j]=j;
		for (int i=1;i<=m;++i)
			for (int j=1;j<=n;++j)
				if (s1[i-1]==s2[j-1])
					t[i][j]=t[i-1][j-1];
				else 
					t[i][j]=Math.min(t[i-1][j-1],Math.min(t[i-1][j],t[i][j-1]));
		return t[m][n];
	}