public static boolean isDistanceOne(String s1, String s2) {
		int m=s1.length(), n=s2.length();
		if (Math.abs(m-n)>1) return false;
		int[][]dp=new int[m+1][n+1];
		for (int i=0;i<=m;++i)dp[i][0]=i;
		for (int j=0;j<=n;++j)dp[0][j]=j;
		for (int i=1;i<=m;++i)
			for (int j=1;j<=n;++j) {
				if (s1.charAt(i-1)==s2.charAt(j-1)) dp[i][j]=dp[i-1][j-1];
				else {
					// delete one character
					dp[i][j]=Math.min(dp[i-1][j], dp[i][j-1]);
					// replace one character
					dp[i][j]=Math.min(dp[i][j], dp[i-1][j-1]);
				}
			}
		return dp[m][n]==1;
	}