
BFS
wutingyehe
Just for fun
展开
-
【LintCode】Number of Island 岛屿的数目
给一个01矩阵,求不同的岛屿的个数。 0代表海,1代表岛,如果两个1相邻,那么这两个1属于同一个岛。我们只考虑上下左右为相邻。样例 在矩阵: [ [1, 1, 0, 0, 0], [0, 1, 0, 0, 1], [0, 0, 0, 1, 1], [0, 0, 0, 0, 0], [0, 0, 0, 0, 1] ] 中有 3 个岛.//广度优先搜索,时间复杂度原创 2015-08-15 17:12:10 · 1915 阅读 · 0 评论 -
【LintCode】在无向图中找出各极大连通子图 Find the Connected Component in the Undirected Graph
Find the number connected component in the undirected graph. Each node in the graph contains a label and a list of its neighbors. (a connected component (or just component) of an undirected graph is a原创 2015-08-16 15:01:27 · 3168 阅读 · 0 评论 -
[LintCode]Segment Tree Build 构造线段树
The structure of Segment Tree is a binary tree which each node has two attributes start and end denote an segment / interval. start and end are both integers, they should be assigned in following rule原创 2015-09-06 11:18:55 · 616 阅读 · 0 评论