@@ -0,0 +1,1424 @@
+/***%0A * Given two strings S and T, determine if they are both one edit distance apart.%0A */%0A/**%0A * Notes: %0A *%0A *   If you try to use the Dynamic Program Algorithm, just like the %60Edit Distance%60, %0A *   Then, you will get %60Memory Limit Error%60 or %60Time Limit Error%60.%0A *%0A *   The Dynamic Program Algorithm which %60Edit Distance%60 prolem used call %60Wagner%E2%80%93Fischer Algorithm%60%0A *   (refer to: http://en.wikipedia.org/wiki/Wagner%25E2%2580%2593Fischer_algorithm)%0A *   Ths DP algorithm's  time complexity is O(m*n), and the space complexity is O(m*n) as well, %0A *   You can optimized the space complexity to O(2*min(m,n)), but it still have %60Time Limit Error%60%0A *%0A *   Fortunately, this problem just for the %60One%60 edit distance, so, this is special case we can solve it by special way.%0A*/%0Apublic class Solution %7B%0A    public boolean isOneEditDistance(String s, String t) %7B%0A        if(Math.abs(s.length() - t.length()) %3E 1) return false;%0A        int n = Math.min(s.length(), t.length());%0A        boolean onediff = false;%0A        for (int i = 0, j = 0; i %3C n && j %3C n; i++, j++) %7B%0A            if (s.charAt(i) == s.charAt(j))%0A                continue;%0A            if (onediff)%0A                return false;%0A            onediff = true;%0A            if (s.length() %3E n)%0A                i--;%0A            else if (t.length() %3E n)%0A                j--;%0A        %7D%0A        return onediff %7C%7C (!onediff && (Math.abs(s.length() - t.length()) == 1));%0A    %7D%0A%7D%0A%0A

add OneEditDistance.java