随笔分类 -  topological sort

310. Minimum Height Trees
摘要:https://leetcode.com/problems/minimum-height-trees/discuss/76055/Share-some-thoughts For a undirected graph with tree characteristics, we can choose any node as the root. The result graph is then a... 阅读全文

posted @ 2018-11-06 09:09 猪猪🐷

444. Sequence Reconstruction
摘要:Check whether the original sequence org can be uniquely reconstructed from the sequences in seqs. The org sequence is a permutation of the integers from 1 to n, with 1 ≤ n ≤ 104. Reconstruction means... 阅读全文

posted @ 2018-11-06 08:37 猪猪🐷

course schedule 2 bfs indegree
摘要:bfs indegree Pretty much the same as the course schedule 1 The only diff is to return the order of the classes, which we can use a list as a container 阅读全文

posted @ 2018-09-08 10:50 猪猪🐷

course schedule 1 bfs indegree
摘要:Use bfs The given is [[1,0]] To take course 1 you should have finished course 0. So it is possible. So we need to convert the input into something lik 阅读全文

posted @ 2018-09-08 10:41 猪猪🐷

269. alien dictionary
摘要:Using “break” in for loop public class Test { public static void main(String args[]) { int [] numbers = {10, 20, 30, 40, 50}; for(int x : numbers ) { 阅读全文

posted @ 2018-08-09 19:00 猪猪🐷

210. Course Schedule II dfs
摘要: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 阅读全文

posted @ 2018-08-09 17:51 猪猪🐷

207. Course Schedule dfs
摘要: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 阅读全文

posted @ 2018-08-09 17:49 猪猪🐷

导航