LeetCode 161 - One Edit Distance


Related: LeetCode Edit Distance
Extended: follow-up 问如果输入不是两个string, 而是char stream怎么办? 这样子就不能用length 来比较了
[LeetCode] One Edit Distance | 程序员达达
Given two strings S and T, determine if they are both one edit distance apart.
Hint:
1. If | n � m | is greater than 1, we know immediately both are not one-edit distance apart.
2. It might help if you consider these cases separately, m == n and m ≠ n.
3. Assume that m is always ≤ n, which greatly simplifies the conditional statements. If m > n, we could just simply swap S and T.
4. If m == n, it becomes finding if there is exactly one modified operation. If m ≠ n, you do not have to consider the delete operation. Just consider the insert operation in T.

https://discuss.leetcode.com/topic/30308/my-clear-java-solution-with-explanation
/*
 * There're 3 possibilities to satisfy one edit distance apart: 
 * 
 * 1) Replace 1 char:
    s: a B c
    t: a D c
 * 2) Delete 1 char from s: 
   s: a D  b c
   t: a    b c
 * 3) Delete 1 char from t
   s: a   b c
   t: a D b c
 */
public boolean isOneEditDistance(String s, String t) {
    for (int i = 0; i < Math.min(s.length(), t.length()); i++) { 
     if (s.charAt(i) != t.charAt(i)) {
      if (s.length() == t.length()) // s has the same length as t, so the only possibility is replacing one char in s and t
       return s.substring(i + 1).equals(t.substring(i + 1));
   else if (s.length() < t.length()) // t is longer than s, so the only possibility is deleting one char from t
    return s.substring(i).equals(t.substring(i + 1));          
   else // s is longer than t, so the only possibility is deleting one char from s
    return t.substring(i).equals(s.substring(i + 1));
     }
    }       
    //All previous chars are the same, the only possibility is deleting the end char in the longer one of s and t 
    return Math.abs(s.length() - t.length()) == 1;        
}
Very smart! It's much clear to figure out how to handle when we find the first different char.

    public boolean isOneEditDistance(String s, String t) {
        int m = s.length(), n = t.length();
        if (Math.abs(m - n) > 1) return false;
        for (int i = 0; i < Math.min(m, n); i++) {
            if (s.charAt(i) == t.charAt(i)) continue;
            if (m == n) return s.substring(i + 1).equals(t.substring(i + 1));
            if (m > n) return s.substring(i + 1).equals(t.substring(i));
            else return s.substring(i).equals(t.substring(i + 1));
        } //return Math.abs(s.length() - t.length()) == 1;  
        return m != n; /* Only last char different. eg."abcd" "abc". Rule out equal case "abc" "abc" */
    }
http://segmentfault.com/a/1190000003906621
虽然我们可以用Edit Distance的解法,看distance是否为1,但Leetcode中会超时。这里我们可以利用只有一个不同的特点在O(N)时间内完成。如果两个字符串只有一个编辑距离,则只有两种情况:
  1. 两个字符串一样长的时候,说明有一个替换操作,我们只要看对应位置是不是只有一个字符不一样就行了
  2. 一个字符串比另一个长1,说明有个增加或删除操作,我们就找到第一个对应位置不一样的那个字符,如果较长字符串在那个字符之后的部分和较短字符串那个字符及之后的部分是一样的,则符合要求
  3. 如果两个字符串长度差距大于1,肯定不对
    public boolean isOneEditDistance(String s, String t) {
        int m = s.length(), n = t.length();
        if(m == n) return isOneModified(s, t);
        if(m - n == 1) return isOneDeleted(s, t);
        if(n - m == 1) return isOneDeleted(t, s);
        // 长度差距大于2直接返回false
        return false;
    }
    
    private boolean isOneModified(String s, String t){
        boolean modified = false;
        // 看是否只修改了一个字符
        for(int i = 0; i < s.length(); i++){
            if(s.charAt(i) != t.charAt(i)){
                if(modified) return false;
                modified = true;
            }
        }
        return modified;
    }
    
    public boolean isOneDeleted(String longer, String shorter){
        // 找到第一组不一样的字符,看后面是否一样
        for(int i = 0; i < shorter.length(); i++){
            if(longer.charAt(i) != shorter.charAt(i)){
                return longer.substring(i + 1).equals(shorter.substring(i));
            }
        }
        return true;
    }
http://codeanalysis111.blogspot.com/2014/12/one-edit-distance.html
     public boolean isOneEditDistance(String s, String t) {
        if(Math.abs(s.length() - t.length()) > 1) return false;
        if(s.length() == t.length()) return isOneSameLength(s, t);
        if(s.length() > t.length()) return isOneDifLength(t, s);
        else return isOneDifLength(s, t);
    }
    private boolean isOneDifLength(String s, String l) {
         int i = 0;
        while(i < s.length() && s.charAt(i) == l.charAt(i)) {++i;}
        if(i == s.length()) return true;
        return s.substring(i).equals(l.substring(i + 1));
    }
    private boolean isOneSameLength(String s, String t) {
        int dif = 0;
        for(int i = 0; i < s.length(); ++i) {
             if(s.charAt(i) != t.charAt(i)) ++dif;
             if(diff>1) return false; // exit early
        }
        return dif == 1;
    }
http://blog.csdn.net/chibaoneliuliuni/article/details/46969869
  1.     public boolean isOneEditDistance(String s, String t) {  
  2.         // make s to be the shorter String  
  3.         if(s.length() > t.length()){  
  4.             return isOneEditDistance(t, s);  
  5.         }  
  6.           
  7.         if(t.length() - s.length() > 1){  
  8.             return false;  
  9.         }          
  10.         int shift = t.length() - s.length();  
  11.         int i = 0;  
  12.         while(i < s.length() && s.charAt(i) == t.charAt(i)){  
  13.             i++;  
  14.         }  
  15.         if(shift == 0){  
  16.             i++;  
  17.             while(i < s.length() && s.charAt(i) == t.charAt(i)){  
  18.                 i++;  
  19.             }  
  20.             return i == s.length();  
  21.         }else{  
  22.             while(i < s.length() && s.charAt(i) == t.charAt(i + 1)){  
  23.                 i++;  
  24.             }  
  25.             return i == s.length();  
  26.         }  
  27.     } 
https://tonycao.gitbooks.io/leetcode-locked/content/LeetCode%20Locked/c1.9.html
O(n) runtime, O(1) space – Simple one-pass:
For the case where m is equal to n, it becomes finding if there is exactly one modified character. Now let’s assume m ≤ n. (If m > n we could just swap them). Assume X represents the one-edit character. There are three one-edit distance operations that could be applied to S.
i. Modify operation – Modify a character to X in S.
ii. Insert operation – X was inserted before a character in S.
iii. Append operation – X was appended at the end of S.
S = “abcde” T = “abXde”
S = “abcde” T = “abcXde”
S = “abcde” T = “abcdeX”
We make a first pass over S and T concurrently and stop at the first non-matching character between S and T.
  1. If S matches all characters in T, then check if there is an extra character at the end of T. (Modify operation)
  2. If | n – m | == 1, that means we must skip this non-matching character only in T and make sure the remaining characters between S and T are exactly matching. (Insert operation)
  3. If | n – m | == 0, then we skip both non-matching characters in S and T and make sure the remaining characters between S and T are exactly matching. (Append operation)
public boolean isOneEditDistance(String s, String t) {
   int m = s.length(), n = t.length();
   if (m > n) return isOneEditDistance(t, s);
   if (n - m > 1) return false;
   int i = 0, shift = n - m;
   while (i < m && s.charAt(i) == t.charAt(i)) i++;
   if (i == m) return shift > 0;
   if (shift == 0) i++;
   while (i < m && s.charAt(i) == t.charAt(i + shift)) i++;
   return i == m;
}

Different solution:
https://leetcode.com/discuss/61772/simple-java-solution
public boolean isOneEditDistance(String s, String t) { if(Math.abs(s.length() - t.length()) > 1) return false; int i = 0, j = 0,err = 0; while(i<s.length() && j<t.length()) { if(s.charAt(i) != t.charAt(j)) { err++; if(err > 1) return false; if(s.length() > t.length()) j--; else if(s.length() < t.length()) i--; } i++; j++; } return (err == 1 || (err == 0 && t.length() != s.length()))? true: false; }
https://leetcode.com/discuss/64603/java-very-simple-w-explanation
public boolean isOneEditDistance(String s, String t) { if (Math.abs(s.length() - t.length()) > 1) { return false; } int diff = s.length() - t.length(); String longer = diff > 0 ? s : t; // potentially longer string String shorter = diff > 0 ? t : s; // potentially shorter string for (int i = 0; i < shorter.length(); i++) { if (longer.charAt(i) != shorter.charAt(i)) { // we allow only one mismatch, afterwards the substrings should match if (diff == 0) { // strings are equal in length, they are only 1 edit distance // apart if substrings cut after index i are equal // ....a[xyz] // ....b[xyz] String longerSubstr = longer.substring(i + 1, longer.length()); String shorterSubstr = shorter.substring(i + 1, shorter.length()); return longerSubstr.equals(shorterSubstr); } else { // longer string is actually longer, substring cut after i should // match substring cut at i on the shorter string // ....a[xyz] // ....[xyz] String longerSubstr = longer.substring(i + 1, longer.length()); String shorterSubstr = shorter.substring(i, shorter.length()); return longerSubstr.equals(shorterSubstr); } } } // at this point we know the potentially longer string matches all of the // potentially shorter string. Only case when this is still one edit distance // apart is if the potentially longer string is actually longer. return diff != 0; }
https://leetcode.com/discuss/71071/my-clear-java-solution-with-explanation
public boolean isOneEditDistance(String s, String t) { for (int i = 0; i < Math.min(s.length(), t.length()); i++) { if (s.charAt(i) != t.charAt(i)) { if (s.length() == t.length()) // s has the same length as t, so the only possibility is replacing one char in s and t return s.substring(i + 1).equals(t.substring(i + 1)); else if (s.length() < t.length()) // t is longer than s, so the only possibility is deleting one char from t return s.substring(i).equals(t.substring(i + 1)); else // s is longer than t, so the only possibility is deleting one char from s return t.substring(i).equals(s.substring(i + 1)); } } //All previous chars are the same, the only possibility is deleting the end char in the longer one of s and t return Math.abs(s.length() - t.length()) == 1; }
https://leetcode.com/discuss/44971/accepted-clean-java-solution-with-explanation-two-pointers
public boolean isOneEditDistance(String s, String t) { if (s == null || t == null) return false; if (s.length() > t.length()) return isOneEditDistance(t, s); int i = 0, j = 0; while (i < s.length() && j < t.length()) { if (s.charAt(i) != t.charAt(j)) { // we try to replace s[i] with s[j] or insert s[j] to s[i] // then compare the rest and see if they are the same return s.substring(i + 1).equals(t.substring(j + 1)) || s.substring(i).equals(t.substring(j + 1)); } i++; j++; } return t.length() - j == 1; }

public boolean isOneEditDistance(String s, String t) { int s_len = s.length(); int t_len = t.length(); if (t_len < s_len) return isOneEditDistance(t, s); if (t_len - s_len > 1) return false; int i = 0; while (i < s_len) { if (s.charAt(i) != t.charAt(i)) return s.substring(i+1).equals(t.substring(i+1)) || s.substring(i).equals(t.substring(i+1)); i++; } return s_len + 1 == t_len; }
https://leetcode.com/discuss/44971/accepted-clean-java-solution-with-explanation-two-pointers
t I think we have no need to maintain index j on String t, since i and j are always in the in the same pace until we return
https://leetcode.com/discuss/54087/easy-understood-java-solution
public boolean isOneEditDistance(String s, String t) { if(Math.abs(s.length()-t.length()) > 1) return false; if(s.length() == t.length()) return isOneModify(s,t); if(s.length() > t.length()) return isOneDel(s,t); return isOneDel(t,s); } public boolean isOneDel(String s,String t){ for(int i=0,j=0;i<s.length() && j<t.length();i++,j++){ if(s.charAt(i) != t.charAt(j)){ return s.substring(i+1).equals(t.substring(j)); } } return true; } public boolean isOneModify(String s,String t){ int diff =0; for(int i=0;i<s.length();i++){ if(s.charAt(i) != t.charAt(i)) diff++; } return diff==1; }
https://leetcode.com/discuss/20038/my-solutions-in-3-languages-with-one-for-loop
for (int i = 0; i < Math.min(s.length(), t.length()); i++) { if (s.charAt(i) != t.charAt(i)) { return s.substring(i + (s.length() >= t.length() ? 1 : 0))
.equals(t.substring(i + (s.length() <= t.length() ? 1 : 0))); } } return Math.abs(s.length() - t.length()) == 1;
https://github.com/mission-peace/interview/blob/master/src/com/interview/recursion/OneEditApart.java
    public boolean matchIterative(char str1[], char str2[]){
        if(str1.length < str2.length){
            char temp[] = str1;
            str1 = str2;
            str2 = temp;
        }
     
        if(str1.length - str2.length > 1){
            return false;
        }
        int k = 1;
        if(str1.length == str2.length){
            int i =0;
            int j =0;
            while(k >= 0 && i < str1.length){
                if(str1[i] != str2[j]){
                    k--;
                }
                i++;
                j++;
            }
            if(k < 0){ // k!=0 depend on the question
                return false;
            }
        }else{
            int i=0;
            int j =0;
            while(k >= 0 && i < str1.length && j < str2.length){
                if(str1[i] != str2[j]){
                    i++;
                    k--;
                    continue;
                }
                i++;
                j++;
            }
            if(k == -1){
                return false;
            }
        }
        return true;
    }
http://www.geeksforgeeks.org/check-if-two-given-strings-are-at-edit-distance-one/
An Efficient Solution is to simultaneously traverse both strings and keep track of count of different characters. Below is complete algorithm.
Let the input strings be s1 and s2 and lengths of input 
strings be m and n respectively.

1) If difference between m an n is more than 1, 
     return false.
2) Initialize count of edits as 1.
3) Start traversing both strings from first character.
    a) If current characters don't match, then
       (i)   Increment count of edits
       (ii)  If count becomes more than 1, return false
       (iii) If length of one string is more, then only
             possible  edit is to remove a character.
             Therefore, move ahead in larger string.
       (iv)  If length is same, then only possible edit
             is to  change a character. Therefore, move
             ahead in both strings. 
    b) Else, move ahead in both strings. 
// Returns true if edit distance between s1 and
// s2 is one, else false
bool isEditDistanceOne(string s1, string s2)
{
    // Find lengths of given strings
    int m = s1.length(), n = s2.length();
    // If difference between lengths is more than
    // 1, then strings can't be at one distance
    if (abs(m - n) > 1)
        return false;
    int count = 0; // Count of edits
    int i = 0, j = 0;
    while (i < m && j < n)
    {
        // If current characters don't match
        if (s1[i] != s2[j])
        {
            if (count == 1)
                return false;
            // If length of one string is
            // more, then only possible edit
            // is to remove a character
            if (m > n)
                i++;
            else if (m< n)
                j++;
            else //Iflengths of both strings is same
            {
                i++;
                j++;
            }
             
            // Increment count of edits
            count++;
        }
        else // If current characters match
        {
            i++;
            j++;
        }
    }
    // If last character is extra in any string
    if (i < m || j < n)
        count++;
    return count == 1;
}
Simple Solution is to find Edit Distance using Dynamic programming. If distance is 1, then return true, else return false. Time complexity of this solution is O(n2)

https://github.com/careercup/CtCI-6th-Edition/tree/master/Java/Ch%2001.%20Arrays%20and%20Strings/Q1_05_One_Away
public static boolean oneEditReplace(String s1, String s2) {
boolean foundDifference = false;
for (int i = 0; i < s1.length(); i++) {
if (s1.charAt(i) != s2.charAt(i)) {
if (foundDifference) {
return false;
}

foundDifference = true;
}
}
return true;
}

/* Check if you can insert a character into s1 to make s2. */
public static boolean oneEditInsert(String s1, String s2) {
int index1 = 0;
int index2 = 0;
while (index2 < s2.length() && index1 < s1.length()) {
if (s1.charAt(index1) != s2.charAt(index2)) {
if (index1 != index2) {
return false;
}
index2++;
} else {
index1++;
index2++;
}
}
return true;
}

public static boolean oneEditAway(String first, String second) {
if (first.length() == second.length()) {
return oneEditReplace(first, second);
} else if (first.length() + 1 == second.length()) {
return oneEditInsert(first, second);
} else if (first.length() - 1 == second.length()) {
return oneEditInsert(second, first);
}
return false;
}
public static boolean oneEditAway(String first, String second) {
/* Length checks. */
if (Math.abs(first.length() - second.length()) > 1) {
return false;
}

/* Get shorter and longer string.*/
String s1 = first.length() < second.length() ? first : second;
String s2 = first.length() < second.length() ? second : first;

int index1 = 0;
int index2 = 0;
boolean foundDifference = false;
while (index2 < s2.length() && index1 < s1.length()) {
if (s1.charAt(index1) != s2.charAt(index2)) {
/* Ensure that this is the first difference found.*/
if (foundDifference) return false;
foundDifference = true;
if (s1.length() == s2.length()) { // On replace, move shorter pointer
index1++;
}
} else {
index1++; // If matching, move shorter pointer
}
index2++; // Always move pointer for longer string
}
return true;
}


Follow-up
Facebook isDistanceZeroOrOne
https://discuss.leetcode.com/topic/25774/c-solution-for-stream-file-where-you-don-t-know-the-length-of-the-strings
If it is a file or stream where you have iterator only moves forward, and you only know the size when you hit the end, we have to split into 3 cases when first difference occurs.
I use s.size() and t.size() in the code but they can be easily translated into iter!=s.end()
Stream processing is much harder for this problem as we cannot compare the length of two strings.
bool isOneEditDistance(string s, string t) {
    int i =0;
    while(i<s.size() && i<t.size() && s[i]==t[i]){
         ++i;
    }
    
    if(i==s.size() && i==t.size()) return false;
    else if(i==s.size() && i+1==t.size() || i==t.size() && i+1==s.size()) return true;
    else if(i<s.size() && i<t.size()){
        ++i;
        bool s1=true, s2=true, s3=true;//3 senarios
        while(i<s.size() && i<t.size()){
          if(s[i]!=t[i-1]) s1=false;
          if(s[i]!=t[i]) s2=false;
          if(s[i-1]!=t[i]) s3=false;
          if(!s1 && !s2 && !s3) return false;
          ++i;
        }
        if(s1 && i+1==s.size() && s[i]==t[i-1]) return true;
        if(s2 && i==s.size() && i==t.size()) return true;
        if(s3 && i+1==t.size() && s[i-1]==t[i]) return true;
        return false;
    }
}
Read full article from [LeetCode] One Edit Distance | 程序员达达

Labels

LeetCode (1432) GeeksforGeeks (1122) LeetCode - Review (1067) Review (882) Algorithm (668) to-do (609) Classic Algorithm (270) Google Interview (237) Classic Interview (222) Dynamic Programming (220) DP (186) Bit Algorithms (145) POJ (141) Math (137) Tree (132) LeetCode - Phone (129) EPI (122) Cracking Coding Interview (119) DFS (115) Difficult Algorithm (115) Lintcode (115) Different Solutions (110) Smart Algorithm (104) Binary Search (96) BFS (91) HackerRank (90) Binary Tree (86) Hard (79) Two Pointers (78) Stack (76) Company-Facebook (75) BST (72) Graph Algorithm (72) Time Complexity (69) Greedy Algorithm (68) Interval (63) Company - Google (62) Geometry Algorithm (61) Interview Corner (61) LeetCode - Extended (61) Union-Find (60) Trie (58) Advanced Data Structure (56) List (56) Priority Queue (53) Codility (52) ComProGuide (50) LeetCode Hard (50) Matrix (50) Bisection (48) Segment Tree (48) Sliding Window (48) USACO (46) Space Optimization (45) Company-Airbnb (41) Greedy (41) Mathematical Algorithm (41) Tree - Post-Order (41) ACM-ICPC (40) Algorithm Interview (40) Data Structure Design (40) Graph (40) Backtracking (39) Data Structure (39) Jobdu (39) Random (39) Codeforces (38) Knapsack (38) LeetCode - DP (38) Recursive Algorithm (38) String Algorithm (38) TopCoder (38) Sort (37) Introduction to Algorithms (36) Pre-Sort (36) Beauty of Programming (35) Must Known (34) Binary Search Tree (33) Follow Up (33) prismoskills (33) Palindrome (32) Permutation (31) Array (30) Google Code Jam (30) HDU (30) Array O(N) (29) Logic Thinking (29) Monotonic Stack (29) Puzzles (29) Code - Detail (27) Company-Zenefits (27) Microsoft 100 - July (27) Queue (27) Binary Indexed Trees (26) TreeMap (26) to-do-must (26) 1point3acres (25) GeeksQuiz (25) Merge Sort (25) Reverse Thinking (25) hihocoder (25) Company - LinkedIn (24) Hash (24) High Frequency (24) Summary (24) Divide and Conquer (23) Proof (23) Game Theory (22) Topological Sort (22) Lintcode - Review (21) Tree - Modification (21) Algorithm Game (20) CareerCup (20) Company - Twitter (20) DFS + Review (20) DP - Relation (20) Brain Teaser (19) DP - Tree (19) Left and Right Array (19) O(N) (19) Sweep Line (19) UVA (19) DP - Bit Masking (18) LeetCode - Thinking (18) KMP (17) LeetCode - TODO (17) Probabilities (17) Simulation (17) String Search (17) Codercareer (16) Company-Uber (16) Iterator (16) Number (16) O(1) Space (16) Shortest Path (16) itint5 (16) DFS+Cache (15) Dijkstra (15) Euclidean GCD (15) Heap (15) LeetCode - Hard (15) Majority (15) Number Theory (15) Rolling Hash (15) Tree Traversal (15) Brute Force (14) Bucket Sort (14) DP - Knapsack (14) DP - Probability (14) Difficult (14) Fast Power Algorithm (14) Pattern (14) Prefix Sum (14) TreeSet (14) Algorithm Videos (13) Amazon Interview (13) Basic Algorithm (13) Codechef (13) Combination (13) Computational Geometry (13) DP - Digit (13) LCA (13) LeetCode - DFS (13) Linked List (13) Long Increasing Sequence(LIS) (13) Math-Divisible (13) Reservoir Sampling (13) mitbbs (13) Algorithm - How To (12) Company - Microsoft (12) DP - Interval (12) DP - Multiple Relation (12) DP - Relation Optimization (12) LeetCode - Classic (12) Level Order Traversal (12) Prime (12) Pruning (12) Reconstruct Tree (12) Thinking (12) X Sum (12) AOJ (11) Bit Mask (11) Company-Snapchat (11) DP - Space Optimization (11) Dequeue (11) Graph DFS (11) MinMax (11) Miscs (11) Princeton (11) Quick Sort (11) Stack - Tree (11) 尺取法 (11) 挑战程序设计竞赛 (11) Coin Change (10) DFS+Backtracking (10) Facebook Hacker Cup (10) Fast Slow Pointers (10) HackerRank Easy (10) Interval Tree (10) Limited Range (10) Matrix - Traverse (10) Monotone Queue (10) SPOJ (10) Starting Point (10) States (10) Stock (10) Theory (10) Tutorialhorizon (10) Kadane - Extended (9) Mathblog (9) Max-Min Flow (9) Maze (9) Median (9) O(32N) (9) Quick Select (9) Stack Overflow (9) System Design (9) Tree - Conversion (9) Use XOR (9) Book Notes (8) Company-Amazon (8) DFS+BFS (8) DP - States (8) Expression (8) Longest Common Subsequence(LCS) (8) One Pass (8) Quadtrees (8) Traversal Once (8) Trie - Suffix (8) 穷竭搜索 (8) Algorithm Problem List (7) All Sub (7) Catalan Number (7) Cycle (7) DP - Cases (7) Facebook Interview (7) Fibonacci Numbers (7) Flood fill (7) Game Nim (7) Graph BFS (7) HackerRank Difficult (7) Hackerearth (7) Inversion (7) Kadane’s Algorithm (7) Manacher (7) Morris Traversal (7) Multiple Data Structures (7) Normalized Key (7) O(XN) (7) Radix Sort (7) Recursion (7) Sampling (7) Suffix Array (7) Tech-Queries (7) Tree - Serialization (7) Tree DP (7) Trie - Bit (7) 蓝桥杯 (7) Algorithm - Brain Teaser (6) BFS - Priority Queue (6) BFS - Unusual (6) Classic Data Structure Impl (6) DP - 2D (6) DP - Monotone Queue (6) DP - Unusual (6) DP-Space Optimization (6) Dutch Flag (6) How To (6) Interviewstreet (6) Knapsack - MultiplePack (6) Local MinMax (6) MST (6) Minimum Spanning Tree (6) Number - Reach (6) Parentheses (6) Pre-Sum (6) Probability (6) Programming Pearls (6) Rabin-Karp (6) Reverse (6) Scan from right (6) Schedule (6) Stream (6) Subset Sum (6) TSP (6) Xpost (6) n00tc0d3r (6) reddit (6) AI (5) Abbreviation (5) Anagram (5) Art Of Programming-July (5) Assumption (5) Bellman Ford (5) Big Data (5) Code - Solid (5) Code Kata (5) Codility-lessons (5) Coding (5) Company - WMware (5) Convex Hull (5) Crazyforcode (5) DFS - Multiple (5) DFS+DP (5) DP - Multi-Dimension (5) DP-Multiple Relation (5) Eulerian Cycle (5) Graph - Unusual (5) Graph Cycle (5) Hash Strategy (5) Immutability (5) Java (5) LogN (5) Manhattan Distance (5) Matrix Chain Multiplication (5) N Queens (5) Pre-Sort: Index (5) Quick Partition (5) Quora (5) Randomized Algorithms (5) Resources (5) Robot (5) SPFA(Shortest Path Faster Algorithm) (5) Shuffle (5) Sieve of Eratosthenes (5) Strongly Connected Components (5) Subarray Sum (5) Sudoku (5) Suffix Tree (5) Swap (5) Threaded (5) Tree - Creation (5) Warshall Floyd (5) Word Search (5) jiuzhang (5)

Popular Posts