
图论
_IanXiao
这个作者很懒,什么都没留下…
展开
-
图论面试题
题目:给你一个描述关系的关系集: i vector<i>表示vector<i>中所有元素依赖于i….有n个依赖关系集。输入一个m,求所有m的最底层依赖。思路:有向图反转边向dfs。 其实就是把邻接表转化成逆邻接表再dfs往下找最底层依赖。 关键是转化成逆邻接表。 dfs往下递归到一条路径的最后一个,再回溯改变边的方向。cur为当前开始点,next=graph[cur][i] 即有cur->ne原创 2016-03-15 19:39:26 · 1625 阅读 · 2 评论 -
LeetCode210. Course Schedule II
题目: https://leetcode.com/problems/course-schedule-ii/ 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 ha原创 2016-03-29 21:00:22 · 529 阅读 · 0 评论 -
LeetCode133. Clone Graph
题目: https://leetcode.com/problems/clone-graph/ Clone an undirected graph. Each node in the graph contains a label and a list of its neighbors.OJ’s undirected graph serialization: Nodes are labeled u原创 2016-03-22 20:04:25 · 401 阅读 · 0 评论 -
PAT1076 Forwards on Weibo
题目链接: http://www.nowcoder.com/pat/5/problem/4306 题目描述:根据微博的关注链,求一条微博可能被转发的最大次数。 x在转发L层的范围内微博可以被转发多少次。输入数据: 7 3 3 2 3 4 0 2 5 6 2 3 1 2 3 4 1 4 1 5 2 2 6共有7个用户,L=3 3 2 3 4 代表用户1关注3个人2、3、4,换原创 2016-01-23 20:28:37 · 440 阅读 · 0 评论 -
LeetCode207. Course Schedule
题目: https://leetcode.com/problems/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原创 2016-03-27 20:50:55 · 413 阅读 · 0 评论