LeetCode 210 - Course Schedule II


LeetCode 210 - Course Schedule II - 我的博客 - ITeye技术网站
Related: LeetCode 207 - Course Schedule
There are a total of n courses you have to take, labeled from 0 to n - 1.
Some courses may have prerequisites, for example to take course 0 you have to first take course 1, which is expressed as a pair: [0,1]
Given the total number of courses and a list of prerequisite pairs, return the ordering of courses you should take to finish all courses.
There may be multiple correct orders, you just need to return one of them. If it is impossible to finish all courses, return an empty array.
For example:
2, [[1,0]] There are a total of 2 courses to take. To take course 1 you should have finished course 0. So the correct course order is [0,1]
4, [[1,0],[2,0],[3,1],[3,2]] There are a total of 4 courses to take. To take course 3 you should have finished both courses 1 and 2. Both courses 1 and 2 should be taken after you finished course 0. So one correct course order is [0,1,2,3]. Another correct ordering is[0,2,1,3].
  1. This problem is equivalent to finding the topological order in a directed graph. If a cycle exists, no topological ordering exists and therefore it will be impossible to take all courses.
  2. Topological Sort via DFS - A great video tutorial (21 minutes) on Coursera explaining the basic concepts of Topological Sort.
  3. Topological sort could also be done via BFS.

X. Topological Sort: BFS + In Degree 0
https://leetcode.com/problems/course-schedule-ii/discuss/59317/Two-AC-solution-in-Java-using-BFS-and-DFS-with-explanation


We observe that if a node has incoming edges, it has prerequisites. Therefore, the first few in the order must be those with no prerequisites, i.e. no incoming edges. Any non-empty DAG must have at least one node without incoming links. You can draw a small graph to convince yourself. If we visit these few and remove all edges attached to them, we are left with a smaller DAG, which is the same problem. This will then give our BFS solution.
private int[] solveByBFS(int[] incLinkCounts, List<List<Integer>> adjs){
    int[] order = new int[incLinkCounts.length];
    Queue<Integer> toVisit = new ArrayDeque<>();
    for (int i = 0; i < incLinkCounts.length; i++) {
        if (incLinkCounts[i] == 0) toVisit.offer(i);
    }
    int visited = 0;
    while (!toVisit.isEmpty()) {
        int from = toVisit.poll();
        order[visited++] = from;
        for (int to : adjs.get(from)) {
            incLinkCounts[to]--;
            if (incLinkCounts[to] == 0) toVisit.offer(to);
        }
    }
    return visited == incLinkCounts.length ? order : new int[0]; 
}https://leetcode.com/discuss/35568/standard-bfs-method-for-course-schedule-ii
public int[] findOrder(int numCourses, int[][] prerequisites) { // for each course in the map nextVertex, the corresponding set contains prerequisite courses for this course Map<Integer, Set<Integer>> nextVertex = new HashMap<>(); // preVertex[i] indicates the number of courses that depend on course i int[] preVertex = new int[numCourses]; // set up nextVertex and preVertex for (int i = 0; i < prerequisites.length; i++) { if (!nextVertex.containsKey(prerequisites[i][0])) { nextVertex.put(prerequisites[i][0], new HashSet<>()); } if (nextVertex.get(prerequisites[i][0]).add(prerequisites[i][1])) { preVertex[prerequisites[i][1]]++; } } // queue for BFS, which will only hold courses currently upon which no other courses depend Deque<Integer> queue = new ArrayDeque<>(); for (int i = 0; i < preVertex.length; i++) { // start from courses upon which no other courses depend. These courses should come last in the order list if (preVertex[i] == 0) { queue.offerLast(i); } } // array for the result, which will be filled up from the end by index int[] res = new int[numCourses]; int index = res.length - 1; while (!queue.isEmpty()) { int key = queue.pollFirst(); // this is a course that no other courses will depend upon res[index--] = key; // so we put it at the end of the order list // since we are done with course "key", for any other course that course "key" is dependent on, we can decrease // the corrresponding preVertex by one and check if it is qualified to be added to the queue. if (nextVertex.containsKey(key)) { for (int i : nextVertex.get(key)) { if (--preVertex[i] == 0) { queue.offerLast(i); } } } --numCourses; // we are done with course "key", so reduce the remaining number of courses by 1 } // if the remaining number of courses is not zero, then we cannot complete all the courses; otherwise return the result return numCourses == 0 ? res : new int[0]; }
https://leetcode.com/discuss/36572/java-code-for-course-schedule-ii
public int[] findOrder(int numCourses, int[][] prerequisites) { if (numCourses <= 0) { return null; } int[] res = new int[numCourses]; int index = 0; if (prerequisites.length == 0 || prerequisites[0].length == 0) { while (index < numCourses) { res[index] = index++; } return res; } int[] course = new int[numCourses]; Map<Integer, List<Integer>> map = new HashMap<Integer, List<Integer>>(); for (int i = 0; i < prerequisites.length; i++) { int val = prerequisites[i][0]; int key = prerequisites[i][1]; if (!map.containsKey(key)) { map.put(key, new ArrayList<Integer>()); } map.get(key).add(val); course[val]++; } Queue<Integer> queue = new LinkedList<Integer>(); for (int i = 0; i < numCourses; i++) { if (course[i] == 0) { queue.add(i); res[index++] = i; } } while (!queue.isEmpty()) { int cur = queue.poll(); if (map.get(cur) != null) { for (int temp : map.get(cur)) { course[temp]--; if (course[temp] == 0) { queue.offer(temp); res[index++] = temp; } } } } for (int i = 0; i < numCourses; i++) { // this cab be improved if (course[i] != 0) { return new int[0]; } } return res; }
http://shibaili.blogspot.com/2015/06/day-107-minimum-size-subarray-sum.html
http://www.programcreek.com/2014/06/leetcode-course-schedule-ii-java/
http://likesky3.iteye.com/blog/2240473
http://blog.csdn.net/yano_nankai/article/details/50215365
只是加了一句话而已,用于保存结果。注意prerequisites为空的时候,任意输出一组结果即可。
public int[] findOrder(int numCourses, int[][] prerequisites) {
    if(prerequisites == null){
        throw new IllegalArgumentException("illegal prerequisites array");
    }
 
    int len = prerequisites.length;
 
    //if there is no prerequisites, return a sequence of courses
    if(len == 0){
        int[] res = new int[numCourses];
        for(int m=0; m<numCourses; m++){
            res[m]=m;
        }
        return res;
    }
 
    //records the number of prerequisites each course (0,...,numCourses-1) requires
    int[] pCounter = new int[numCourses];
    for(int i=0; i<len; i++){
        pCounter[prerequisites[i][0]]++;
    }
 
    //stores courses that have no prerequisites
    LinkedList<Integer> queue = new LinkedList<Integer>();
    for(int i=0; i<numCourses; i++){
        if(pCounter[i]==0){
            queue.add(i);
        }
    }
 
    int numNoPre = queue.size();
 
    //initialize result
    int[] result = new int[numCourses];
    int j=0;
 
    while(!queue.isEmpty()){
        int c = queue.remove();
        result[j++]=c;
 
        for(int i=0; i<len; i++){
            if(prerequisites[i][1]==c){
                pCounter[prerequisites[i][0]]--;
                if(pCounter[prerequisites[i][0]]==0){
                    queue.add(prerequisites[i][0]);
                    numNoPre++;
                }
            }
 
        }
    }
 
    //return result
    if(numNoPre==numCourses){
        return result;
    }else{
        return new int[0];
    }
}
http://blog.csdn.net/xudli/article/details/45912519
    public int[] findOrder(int numCourses, int[][] prerequisites) {
        int[] map = new int[numCourses];
        int n = prerequisites.length;
        int[] res = new int[numCourses];
        
        for(int i=0; i<n; i++) {
            map[ prerequisites[i][1] ] ++;
        }
        
        Queue<Integer> que = new LinkedList<Integer>();
        int index = numCourses-1;
        for(int i=0; i<numCourses; i++) {
            if(map[i] == 0) {
                que.add(i);
                res[index--] = i;
            }
        }
        
        while(!que.isEmpty() ){
            int k = que.remove();
            for(int i=0; i<n; i++) {
                int l = prerequisites[i][1];
                if(k==prerequisites[i][0]) {
                    map[l]--;
                    if(map[l] == 0) {
                        que.add(l);
                        res[index--] = l;
                    }
                }
            }
        }
        if(index!=-1) return new int[0];
        else return res;
    }
https://leetcode.com/discuss/85141/java-6ms-topological-sort-solution-with-explanation
public int[] findOrder(int numCourses, int[][] prerequisites) { int[] inDeg = new int[numCourses]; List<Integer>[] chl = new ArrayList[numCourses]; for (int i = 0; i < numCourses; i++) { chl[i] = new ArrayList<Integer>(); } int pre; int cour; for (int[] pair : prerequisites) { pre = pair[1]; cour = pair[0]; chl[pre].add(cour); inDeg[cour]++; } int[] res = new int[numCourses]; int k = 0; for (int i = 0; i < numCourses; i++) { if (inDeg[i] == 0) { res[k++] = i; } } if (k == 0) { return new int[0]; } int j = 0; List<Integer> tmp; while (k < numCourses) { tmp = chl[res[j++]]; for (int id : tmp) { if (--inDeg[id] == 0) { res[k++] = id; } } if (j == k) {//??\\ return new int[0]; } } return res; }
X. DFS + Topological Sort
https://leetcode.com/problems/course-schedule-ii/discuss/59342/Java-DFS-double-cache-visiting-each-vertex-once-433ms
    public int[] findOrder(int numCourses, int[][] prerequisites) {
        List<List<Integer>> adj = new ArrayList<>(numCourses);
        for (int i = 0; i < numCourses; i++) adj.add(i, new ArrayList<>());
        for (int i = 0; i < prerequisites.length; i++) adj.get(prerequisites[i][1]).add(prerequisites[i][0]);
        boolean[] visited = new boolean[numCourses];
        Stack<Integer> stack = new Stack<>();
        for (int i = 0; i < numCourses; i++) {
            if (!topologicalSort(adj, i, stack, visited, new boolean[numCourses])) return new int[0];
        }
        int i = 0;
        int[] result = new int[numCourses];
        while (!stack.isEmpty()) {
            result[i++] = stack.pop();
        }
        return result;
    }
    
    private boolean topologicalSort(List<List<Integer>> adj, int v, Stack<Integer> stack, boolean[] visited, boolean[] isLoop) {
        if (visited[v]) return true;
        if (isLoop[v]) return false;
        isLoop[v] = true;
        for (Integer u : adj.get(v)) {
            if (!topologicalSort(adj, u, stack, visited, isLoop)) return false;
        }
        visited[v] = true;
        stack.push(v);
        return true;
    }

Another way to think about it is the last few in the order must be those which are not prerequisites of other courses. Thinking it recursively means if one node has unvisited child node, you should visit them first before you put this node down in the final order array. This sounds like the post-order of a DFS. Since we are putting nodes down in the reverse order, we should reverse it back to correct ordering or use a stack.
private int[] solveByDFS(List<List<Integer>> adjs) {
    BitSet hasCycle = new BitSet(1);
    BitSet visited = new BitSet(adjs.size());
    BitSet onStack = new BitSet(adjs.size());
    Deque<Integer> order = new ArrayDeque<>();
    for (int i = adjs.size() - 1; i >= 0; i--) {
        if (visited.get(i) == false && hasOrder(i, adjs, visited, onStack, order) == false) return new int[0];
    }
    int[] orderArray = new int[adjs.size()];
    for (int i = 0; !order.isEmpty(); i++) orderArray[i] = order.pop();
    return orderArray;
}

private boolean hasOrder(int from, List<List<Integer>> adjs, BitSet visited, BitSet onStack, Deque<Integer> order) {
    visited.set(from);
    onStack.set(from);
    for (int to : adjs.get(from)) {
        if (visited.get(to) == false) {
            if (hasOrder(to, adjs, visited, onStack, order) == false) return false;
        } else if (onStack.get(to) == true) {
            return false;
        }
    }
    onStack.clear(from);
    order.push(from);
    return true;
}
https://cheonhyangzhang.wordpress.com/2015/10/14/210-leetcode-java-course-schedule-ii-medium/
    int index = 0;
    public int[] findOrder(int numCourses, int[][] prerequisites) {
        HashMap<Integer, List<Integer>> adj = new HashMap<Integer, List<Integer>>();
        int n = numCourses;
        index = n - 1;
        int[][] pre = prerequisites;//make another reference to make variable name shorter
        int[] result = new int[n];
        initAdj(n, adj, pre);
        int[] color = new int[n];//0 white 1 gray 2 black
        for (int i = 0; i < n; i ++){
            if (!canFinishDFS(adj, color, result, i)){
                return new int[0];
            }
        }//for i
        return result;
    }
    private void initAdj(int n, HashMap<Integer, List<Integer>> adj, int[][] pre){
        for (int i = 0; i < n; i ++){
            adj.put(i, new LinkedList<Integer>());
        }
        for (int i = 0; i < pre.length; i ++){
            adj.get(pre[i][1]).add(pre[i][0]);
        }
    }
    private boolean canFinishDFS(HashMap<Integer, List<Integer>> adj, int[] color, int[] result, int i){
        if (color[i] == 1)
            return false;
        if (color[i] == 2)
            return true;
        color[i] = 1;
        for (Integer j:adj.get(i)){
            if (!canFinishDFS(adj, color, result, j)){
                return false;
            }
        }
        color[i] = 2;
        result[index] = i;
        index --;
        return true;
    }

  1. vector<int> findOrder(int numCourses, vector<pair<intint>>& prerequisites) {  
  2.     vector<list<int>> adj(numCourses, list<int>());  
  3.     vector<bool> visited(numCourses, false);  
  4.     vector<bool> onstack(numCourses, false);  
  5.     vector<int> order;  
  6.       
  7.     for(auto& it : prerequisites) {  
  8.         adj[it.second].push_back(it.first);  
  9.     }  
  10.       
  11.     for(int i=0; i<numCourses; ++i) {  
  12.         if(visited[i]) continue;  
  13.         if(hasCycle(adj, i, visited, onstack, order)) return vector<int>();  
  14.     }  
  15.     return order;  
  16. }  
  17.   
  18. bool hasCycle(vector<list<int>>& adj, int v, vector<bool>& visited, vector<bool>& onstack, vector<int>& order) {  
  19.     visited[v] = true;  
  20.     onstack[v] = true;  
  21.     for(auto& it : adj[v]) {  
  22.         if(!visited[it] && hasCycle(adj, it, visited, onstack, order)) return true;  
  23.         if(onstack[it]) return true;  
  24.     }  
  25.     order.insert(order.begin(), v);  
  26.     onstack[v] = false;  
  27.     return false;  
topological sort, 考虑cycle问题
http://sgq626.blogspot.com/2015/07/leetcode-207leetcode-210-course.html
 topological sort DFS写法的一般思路: DFS+ mark visit III, 每次当一个点被mark成visited,之后将这个点加入rst中。
注意在用DFS + mark visit III之前,graph的表示是 course ->  pre-dependency,与判断directed graph里面有没有circle是相反的表示方式。
 Empty list that will contain the sorted nodes
for each of the node n in the graph do
visit(n)

function visit(node n)
if n is visited then return   
if n is visiting then stop (not a DAG, there is a cycle)
if n is not visited or visiting then
mark n visiting
                        for each node m which is n’s dependency do            
visit(m)        
      mark n visited        
      add n to head of L
    bool visit(int start, unordered_map<int, vector<int>> &gmap, int *M, vector<int> &rst) {
        //base case
        if (M[start] == 1) return true;
        if (M[start] == -1) return false; //cycle
        //mark
        M[start] = -1;//mark visiting
        for (int i = 0; i < gmap[start].size();i++) {
            if (visit(gmap[start][i], gmap, M, rst) == false) return false;
        }
        M[start] = 1; //visited
        rst.push_back(start);
        return true;
    }
public:
    vector<int> findOrder(int numCourses, vector<pair<int, int>>& prerequisites) {
        vector<int> rst;
        unordered_map<int, vector<int>> gmap;
        for (int i = 0; i < prerequisites.size(); i++) {
            gmap[prerequisites[i].first].push_back(prerequisites[i].second);
        }
        //vector<int> M(numCourses, 0);
        int M[numCourses] = {0};
        //for each node in the graph do visit n
        for (int i = 0; i < numCourses; i++) {
            if (visit(i, gmap, M, rst) == false) {
                rst.clear();
                break;
            }
        }
        return rst;
    }
https://leetcode.com/discuss/42710/java-dfs-double-cache-visiting-each-vertex-once-433ms
-- better to use int[] to cache
public int[] findOrder(int numCourses, int[][] prerequisites) { List<List<Integer>> adj = new ArrayList<>(numCourses); for (int i = 0; i < numCourses; i++) adj.add(i, new ArrayList<>()); for (int i = 0; i < prerequisites.length; i++) adj.get(prerequisites[i][1]).add(prerequisites[i][0]); boolean[] visited = new boolean[numCourses]; Stack<Integer> stack = new Stack<>(); for (int i = 0; i < numCourses; i++) { if (!topologicalSort(adj, i, stack, visited, new boolean[numCourses])) return new int[0]; } int i = 0; int[] result = new int[numCourses]; while (!stack.isEmpty()) { result[i++] = stack.pop(); } return result; } private boolean topologicalSort(List<List<Integer>> adj, int v, Stack<Integer> stack, boolean[] visited, boolean[] isLoop) { if (visited[v]) return true; if (isLoop[v]) return false; isLoop[v] = true; for (Integer u : adj.get(v)) { if (!topologicalSort(adj, u, stack, visited, isLoop)) return false; } visited[v] = true; stack.push(v); return true; }

https://leetcode.com/discuss/35605/two-ac-solution-in-java-using-bfs-and-dfs-with-explanation
Use BitSet
private int[] solveByDFS(List<List<Integer>> adjs) { BitSet hasCycle = new BitSet(1); BitSet visited = new BitSet(adjs.size()); BitSet onStack = new BitSet(adjs.size()); Deque<Integer> order = new ArrayDeque<>(); for (int i = adjs.size() - 1; i >= 0; i--) { if (visited.get(i) == false && hasOrder(i, adjs, visited, onStack, order) == false) return new int[0]; } int[] orderArray = new int[adjs.size()]; for (int i = 0; !order.isEmpty(); i++) orderArray[i] = order.pop(); return orderArray; } private boolean hasOrder(int from, List<List<Integer>> adjs, BitSet visited, BitSet onStack, Deque<Integer> order) { visited.set(from); onStack.set(from); for (int to : adjs.get(from)) { if (visited.get(to) == false) { if (hasOrder(to, adjs, visited, onStack, order) == false) return false; } else if (onStack.get(to) == true) { return false; } } onStack.clear(from); order.push(from); return true; }
http://shibaili.blogspot.com/2015/06/day-107-minimum-size-subarray-sum.html
Read full article from LeetCode 210 - Course Schedule II - 我的博客 - ITeye技术网站

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