LeetCode 425 - Word Squares


http://bookshadow.com/weblog/2016/10/16/leetcode-word-squares/
Given a set of words (without duplicates), find all word squares you can build from them.
A sequence of words forms a valid word square if the kth row and column read the exact same string, where 0 ≤ k < max(numRows, numColumns).
For example, the word sequence ["ball","area","lead","lady"] forms a word square because each word reads the same both horizontally and vertically.
b a l l
a r e a
l e a d
l a d y
Note:
  1. There are at least 1 and at most 1000 words.
  2. All words will have the exact same length.
  3. Word length is at least 1 and at most 5.
  4. Each word contains only lowercase English alphabet a-z.
Example 1:
Input:
["area","lead","wall","lady","ball"]

Output:
[
  [ "wall",
    "area",
    "lead",
    "lady"
  ],
  [ "ball",
    "area",
    "lead",
    "lady"
  ]
]

Explanation:
The output consists of two word squares. The order of output does not matter (just the order of words in each word square matters).
Example 2:
Input:
["abat","baba","atan","atal"]

Output:
[
  [ "baba",
    "abat",
    "baba",
    "atan"
  ],
  [ "baba",
    "abat",
    "baba",
    "atal"
  ]
]

Explanation:
The output consists of two word squares. The order of output does not matter (just the order of words in each word square matters).
X. DFS
https://zhuhan0.blogspot.com/2017/09/leetcode-425-word-squares.html
Store all words into a trie. Iterate through the words.
  • For each word:
    • create a new list. Add the word into the list.
    • Search the trie for all the words that have the correct prefix. For each of these words:
      • Add it to the list.
      • Continue searching for the next prefix recursively.
      • The recursion reaches its base case when the size of the list is equal to the length of a word. In this case, we've found a word square.
Time complexity:
Say there are n words, the words' length is l, and each trie node has c children on average. buildTrie() takes O(ln). wordSquares() helper method takes O(c^l). So the for loop takes O(nc^l). The overall time complexity is O(ln + nc^l).
    class TrieNode {
        TrieNode[] children;
        boolean isWord;
        
        TrieNode() {
            children = new TrieNode[26];
        }
    }
    
    public List<List<String>> wordSquares(String[] words) {
        TrieNode root = buildTrie(words);
        List<List<String>> squares = new ArrayList<>();
        
        for (String word : words) {
            List<String> square = new ArrayList<>();
            square.add(word);
            wordSquares(root, word.length(), square, squares);
        }
        return squares;
    }
    
    private TrieNode buildTrie(String[] words) {
        TrieNode root = new TrieNode();
        for (String word : words) {
            TrieNode current = root;
            for (char c : word.toCharArray()) {
                int index = c - 'a';
                if (current.children[index] == null) {
                    current.children[index] = new TrieNode();
                }
                current = current.children[index];
            }
            current.isWord = true;
        }
        return root;
    }
    
    private TrieNode search(TrieNode root, String prefix) {
        TrieNode current = root;
        for (char c : prefix.toCharArray()) {
            int index = c - 'a';
            if (current.children[index] == null) {
                return null;
            }
            current = current.children[index];
        }
        return current;
    }
    
    private void wordSquares(TrieNode root, int len, List<String> square, List<List<String>> squares) {
        if (square.size() == len) {
            squares.add(new ArrayList<>(square));
            return;
        }

        String prefix = getPrefix(square, square.size());
        TrieNode node = search(root, prefix);
        if (node == null) {
            return;
        }
        
        List<String> children = new ArrayList<>();
        getChildren(node, prefix, children);
        for (String child : children) {
            square.add(child);
            wordSquares(root, len, square, squares);
            square.remove(square.size() - 1);
        }
    }
    
    private String getPrefix(List<String> square, int index) {
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < index; i++) {
            sb.append(square.get(i).charAt(index));
        }
        return sb.toString();
    }
    
    private void getChildren(TrieNode node, String s, List<String> children) {
        if (node.isWord) {
            children.add(s);
            return;
        }
        
        for (int i = 0; i < 26; i++) {
            if (node.children[i] != null) {
                getChildren(node.children[i], s + (char) ('a' + i), children);
            }
        }
    }
https://discuss.leetcode.com/topic/63516/explained-my-java-solution-using-trie-126ms-16-16
My first approach is brute-force, try every possible word sequences, and use the solution of Problem 422 (https://leetcode.com/problems/valid-word-square/) to check each sequence. This solution is straightforward, but too slow (TLE).
A better approach is to check the validity of the word square while we build it.
Example: ["area","lead","wall","lady","ball"]
We know that the sequence contains 4 words because the length of each word is 4.
Every word can be the first word of the sequence, let's take "wall" for example.
Which word could be the second word? Must be a word start with "a" (therefore "area"), because it has to match the second letter of word "wall".
Which word could be the third word? Must be a word start with "le" (therefore "lead"), because it has to match the third letter of word "wall" and the third letter of word "area".
What about the last word? Must be a word start with "lad" (therefore "lady"). For the same reason above.
The picture below shows how the prefix are matched while building the sequence.
0_1476809138708_wordsquare.png
In order for this to work, we need to fast retrieve all the words with a given prefix. There could be 2 ways doing this:
  1. Using a hashtable, key is prefix, value is a list of words with that prefix.
  2. Trie, we store a list of words with the prefix on each trie node.
One pic to help understand the Trie structure.
The only difference between the trie here and the normal trie is that we hold one more list of all the words which have the prefix(from the root char to the current node char).
alt text

    class TrieNode {
        List<String> startWith;
        TrieNode[] children;

        TrieNode() {
            startWith = new ArrayList<>();
            children = new TrieNode[26];
        }
    }

    class Trie {
        TrieNode root;

        Trie(String[] words) {
            root = new TrieNode();
            for (String w : words) {
                TrieNode cur = root;
                for (char ch : w.toCharArray()) {
                    int idx = ch - 'a';
                    if (cur.children[idx] == null)
                        cur.children[idx] = new TrieNode();
                    cur.children[idx].startWith.add(w);
                    cur = cur.children[idx];
                }
            }
        }

        List<String> findByPrefix(String prefix) {
            List<String> ans = new ArrayList<>();
            TrieNode cur = root;
            for (char ch : prefix.toCharArray()) {
                int idx = ch - 'a';
                if (cur.children[idx] == null)
                    return ans;

                cur = cur.children[idx];
            }
            ans.addAll(cur.startWith);
            return ans;
        }
    }

    public List<List<String>> wordSquares(String[] words) {
        List<List<String>> ans = new ArrayList<>();
        if (words == null || words.length == 0)
            return ans;
        int len = words[0].length();
        Trie trie = new Trie(words);
        List<String> ansBuilder = new ArrayList<>();
        for (String w : words) {
            ansBuilder.add(w);
            search(len, trie, ans, ansBuilder);
            ansBuilder.remove(ansBuilder.size() - 1);
        }

        return ans;
    }

    private void search(int len, Trie tr, List<List<String>> ans,
            List<String> ansBuilder) {
        if (ansBuilder.size() == len) {
            ans.add(new ArrayList<>(ansBuilder));
            return;
        }

        int idx = ansBuilder.size();
        StringBuilder prefixBuilder = new StringBuilder();
        for (String s : ansBuilder)
            prefixBuilder.append(s.charAt(idx));
        List<String> startWith = tr.findByPrefix(prefixBuilder.toString());
        for (String sw : startWith) {
            ansBuilder.add(sw);
            search(len, tr, ans, ansBuilder);
            ansBuilder.remove(ansBuilder.size() - 1);
        }
    }
https://discuss.leetcode.com/topic/63532/121ms-java-solution-using-trie-and-backtracking
    TrieNode root = new TrieNode();
    public List<List<String>> wordSquares(String[] words) {
        List<List<String>> ans = new ArrayList<>();
        if(words.length == 0) return ans;
        buildTrie(words);
        int length = words[0].length();
        findSquare(ans, length, new ArrayList<>());
        return ans;
    }
    
    private void findSquare(List<List<String>> ans, int length, List<String> temp) {
        if(temp.size() == length) {
            ans.add(new ArrayList<>(temp));
            return;
        }
        int index = temp.size();
        StringBuilder sb = new StringBuilder();
        for(String s : temp) {
            sb.append(s.charAt(index));
        }
        String s = sb.toString();
        TrieNode node = root;
        for(int i = 0; i < s.length(); i++) {
            if(node.next[s.charAt(i) - 'a'] != null) {
                node = node.next[s.charAt(i) - 'a'];
            } else {
                node = null;
                break;
            }
        }
        if(node != null) {
            for(String next : node.words) {
                temp.add(next);
                findSquare(ans, length, temp);
                temp.remove(temp.size() - 1);
            }
        }
    }
    
    private void buildTrie(String[] words) {
        for(String word : words) {
            TrieNode node = root;
            char[] array = word.toCharArray();
            for(char c : array) {
                node.words.add(word);
                if(node.next[c - 'a'] == null) {
                    node.next[c - 'a'] = new TrieNode();
                }
                node = node.next[c - 'a'];
            }
            node.words.add(word);
        }
    }
    
    class TrieNode {
        TrieNode[] next = new TrieNode[26];
        List<String> words = new ArrayList<>();
    }

https://discuss.leetcode.com/topic/63417/181-ms-java-solution-intuitive-backtracking
http://bookshadow.com/weblog/2016/10/16/leetcode-word-squares/
深度优先搜索(DFS)+ 剪枝(Pruning)
首先构建一个单词前缀prefix->单词word的字典mdict

深度优先搜索search(word, line),其中word是当前单词,line是行数

利用变量matrix记录当前已经生成的单词

前缀prefix = matrix[0..line][line],如果prefix对应单词不存在,则可以剪枝

否则枚举mdict[prefix],并递归搜索

X. Using Trie
https://discuss.leetcode.com/topic/63516/my-java-solution-using-trie
 class TrieNode {
  List<String> startWith;
  TrieNode[] children;

  TrieNode() {
   startWith = new ArrayList<>();
   children = new TrieNode[26];
  }
 }

 class Trie {
  TrieNode root;

  Trie(String[] words) {
   root = new TrieNode();
   for (String w : words) {
    TrieNode cur = root;
    for (char ch : w.toCharArray()) {
     int idx = ch - 'a';
     if (cur.children[idx] == null)
      cur.children[idx] = new TrieNode();
     cur.children[idx].startWith.add(w);
     cur = cur.children[idx];
    }
   }
  }

  List<String> findPrefix(String prefix) {
   List<String> ans = new ArrayList<>();
   TrieNode cur = root;
   for (char ch : prefix.toCharArray()) {
    int idx = ch - 'a';
    if (cur.children[idx] == null)
     return ans;

    cur = cur.children[idx];
   }
   ans.addAll(cur.startWith);
   return ans;
  }
 }

 public List<List<String>> wordSquares(String[] words) {
  List<List<String>> ans = new ArrayList<>();
  if (words == null || words.length == 0)
   return ans;
  int n = words.length;
  int len = words[0].length();
  Trie trie = new Trie(words);
  List<String> ansBuilder = new ArrayList<>();
  for (String w : words) {
   ansBuilder.add(w);
   search(words, n, len, trie, ans, ansBuilder);
   ansBuilder.remove(ansBuilder.size() - 1);
  }

  return ans;
 }

 private void search(String[] ws, int n, int len, Trie tr,
   List<List<String>> ans, List<String> ansBuilder) {
  if (ansBuilder.size() == len) {
   ans.add(new ArrayList<>(ansBuilder));
   return;
  }

  int idx = ansBuilder.size();
  StringBuilder prefix = new StringBuilder();
  for (String s : ansBuilder)
   prefix.append(s.charAt(idx));
  List<String> startWith = tr.findPrefix(prefix.toString());
  for (String sw : startWith) {
   ansBuilder.add(sw);
   search(ws, n, len, tr, ans, ansBuilder);
   ansBuilder.remove(ansBuilder.size() - 1);
  }
 }
https://discuss.leetcode.com/topic/64770/java-dfs-trie-54-ms-98-so-far/2
X. https://segmentfault.com/a/1190000008454085
w a l l
a r e a
l e a d
l a d y
在给定的词典里,找到一些单词,组成一个square, 第i行和第i列一样。
(0,0) 这个点找到满足条件的,我们选择w。
(0,1) 我们要满足wa, a都可以作为开头的部分。
(0,2) 我们要满足wal, l都可以作为开头的部分。
按照代码的逻辑,走一遍test case, 填写好prefix[]每一步被更新的样子。
0行。     
开始    prefix[root, root, root, root] 
(0, 0) prefix[root, root, root, root]  (root.w, root.w)  root[0] = w, root[0] = w
(0, 1) prefix[w, root, root, root]     (w.a, root.a)     root[0] = wa, root[1] = a
(0, 2) prefix[wa, a, root, root]     (wa.l, root.l)     root[0] = wal, root[2] = l
(0, 3) prefix[wal, a, l, root]     (wal.l, root.l)     root[0] = wall, root[3] = l
结束     prefix[wall, a, l, l] 

第1行。
开始    prefix[wall, a, l, l]

(1,1)  prefix[wall, a, l, l]       (a.r, a.r)     root[1] = ar,  root[1] = ar
(1,2)  prefix[wall, ar, l, l]      (ar.e, l.e)    root[1] = are, root[2] = le
(1,3)  prefix[wall, are, le, l]      (are.a, l.a)    root[1] = area, root[3] =la
结束    prefix[wall, area, le, la] 


public class Solution {
    class Node{
        String word = null;
        Node[] kids = new Node[26];
    }
    
    private Node root = new Node();
    
    private void buildTrie(String word, Node par){
        for(char c: word.toCharArray()){
            int idx = c -'a';
            if(par.kids[idx] == null) par.kids[idx] = new Node();
            par = par.kids[idx];
        }
        par.word = word;
    }
    
    private void findAllSquares(int row , int col, Node[] prefix, List<List<String>> res){
        if(row == prefix.length){
            List<String> temp = new ArrayList<String>();
            for(int i=0; i<prefix.length; i++){
                temp.add(prefix[i].word);
            }
            res.add(temp);
        } else if(col < prefix.length){ 
            Node currow = prefix[row];  
            Node curcol = prefix[col];
            for(int i=0; i<26; i++){
                if(currow.kids[i] != null && curcol.kids[i] != null){   // 同一层从左向右走的时候
                    prefix[row] =  currow.kids[i];      //  prefix[row]会不断增长,直到最后形成以个单词
                    prefix[col] =  curcol.kids[i];      //  prefix[col]相应位置长度加一,更新prefix
                    findAllSquares(row, col+1, prefix, res);   
                }
            }
            prefix[row] = currow;       // reset back  重新进行下一次的搜索。
            prefix[col] = curcol;
        } else {
            findAllSquares(row+1, row+1, prefix, res);
        }
    }
    
    public List<List<String>> wordSquares(String[] words) {
        List<List<String>> res = new ArrayList<List<String>>();
        if(words == null || words.length == 0 || words[0] == null || words[0].length() == 0) return res;
        for(String word: words){
            buildTrie(word, root);
        }
        Node[] prefix = new Node[words[0].length()];
        Arrays.fill(prefix, root);
        findAllSquares(0, 0, prefix, res);
        return res;
    }
}
X. http://www.cnblogs.com/grandyang/p/6006000.html
那么根据以往的经验,对于这种要打印出所有情况的题的解法大多都是用递归来解,那么这题的关键是根据前缀来找单词,我们如果能利用合适的数据结构来建立前缀跟单词之间的映射,使得我们能快速的通过前缀来判断某个单词是否存在,这是解题的关键。对于建立这种映射,这里主要有两种方法,一种是利用哈希表来建立前缀和所有包含此前缀单词的集合之前的映射,第二种方法是建立前缀树Trie,顾名思义,前缀树专门就是为这种问题设计的。那么我们首先来看第一种方法,用哈希表来建立映射的方法,我们就是取出每个单词的所有前缀,然后将该单词加入该前缀对应的集合中去,然后我们建立一个空的nxn的char矩阵,其中n为单词的长度,我们的目标就是来把这个矩阵填满,我们从0开始遍历,我们先取出长度为0的前缀,即空字符串,由于我们在建立映射的时候,空字符串也和每个单词的集合建立了映射,然后我们遍历这个集合,用遍历到的单词的i位置字符,填充矩阵mat[i][i],然后j从i+1出开始遍历,对应填充矩阵mat[i][j]和mat[j][i],然后我们根据第j行填充得到的前缀,到哈希表中查看有没单词,如果没有,就break掉,如果有,则继续填充下一个位置。最后如果j==n了,说明第0行和第0列都被填好了,我们再调用递归函数,开始填充第一行和第一列,依次类推,直至填充完成
    vector<vector<string>> wordSquares(vector<string>& words) {
        vector<vector<string>> res;
        unordered_map<string, set<string>> m;
        int n = words[0].size();
        for (string word : words) {
            for (int i = 0; i < n; ++i) {
                string key = word.substr(0, i);
                m[key].insert(word);
            }
        }
        vector<vector<char>> mat(n, vector<char>(n));
        helper(0, n, mat, m, res);
        return res;
    }
      void helper(int i, int n, vector<vector<char>>& mat, unordered_map<string, set<string>>& m, vector<vector<string>>& res) {
            if (i == n) {
                vector<string> out;
                for (int j = 0; j < n; ++j) out.push_back(string(mat[j].begin(), mat[j].end()));
                res.push_back(out);
                return;
            }
            string key = string(mat[i].begin(), mat[i].begin() + i);
        for (string str : m[key]) { 
            mat[i][i] = str[i];
            int j = i + 1;
            for (; j < n; ++j) {
                mat[i][j] = str[j];
                mat[j][i] = str[j];
                if (!m.count(string(mat[j].begin(), mat[j].begin() + i + 1))) break;
            }
            if (j == n) helper(i + 1, n, mat, m, res);
        }
    }


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