BFS
iyangdi
这个作者很懒,什么都没留下…
展开
-
Google/LintCode:M-图是否是树
题目题目来源:Link给出 n 个节点,标号分别从 0 到 n - 1 并且给出一个 无向 边的列表 (给出每条边的两个顶点), 写一个函数去判断这张`无向`图是否是一棵树 注意事项你可以假设我们不会给出重复的边在边的列表当中. 无向边 [0, 1] 和 [1, 0] 是同一条边, 因此他们不会同时出现在我们给你的边的列表当中。原创 2017-08-10 11:27:02 · 355 阅读 · 0 评论 -
LintCode:M-克隆图
lintCode链接克隆一张无向图,图中的每个节点包含一个 label 和一个列表 neighbors。数据中如何表示一个无向图?http://www.lintcode.com/help/graph/你的程序需要返回一个经过深度拷贝的新图。这个新图和原图具有同样的结构,并且对新图的任何改动不会对原图造成任何影响。您在真实的面试中是否遇到过这个题?原创 2017-08-28 22:03:19 · 328 阅读 · 0 评论 -
LeetCode:M-547. Friend Circles
LeetCode链接There are N students in a class. Some of them are friends, while some are not. Their friendship is transitive in nature. For example, if A is a direct friend of B, and B is a direc原创 2017-09-25 17:48:57 · 381 阅读 · 0 评论