上一页 1 ··· 7 8 9 10 11 12 13 14 15 ··· 44 下一页
摘要: 转载:转载请注明出处:勿在浮沙筑高台http://blog.csdn.net/luoshixian099/article/details/51908175 一.Prim算法 适用于:边较多时 加点法: 时间复杂度:O(V^2) 在已得最小生成树各个节点,(绿色set:A,C,G) 向外部其他节点的节 阅读全文
posted @ 2021-03-06 13:01 habibah_chang 阅读(115) 评论(0) 推荐(0) 编辑
摘要: 问题: 给定一个无向图,graph[i]={a,b,c...} 代表:节点 i 的邻接节点有 节点 a,b,c... ⚠️ 这里若有graph[a]中包含b,那么graph[b]中也包含a。 求将这个图中的节点分为两个集合, 任意相邻两个节点,都分别位于两个集合中。 是否能行。 Example 1: 阅读全文
posted @ 2021-03-05 15:49 habibah_chang 阅读(51) 评论(0) 推荐(0) 编辑
摘要: 问题: 给定N叉树,将各个节点的值,按【层】构成数组输出。 Example 1: Input: root = [1,null,3,2,4,null,5,6] Output: [[1],[3,2,4],[5,6]] Example 2: Input: root = [1,null,2,3,4,5,nu 阅读全文
posted @ 2021-03-05 15:10 habibah_chang 阅读(41) 评论(0) 推荐(0) 编辑
摘要: 转载:[图的最短路径算法]Dijkstra, Bellman-Ford, Floyd-Warshall 一. Dijkstra算法 ⚠️ 注意:不能解决含有负权的图。 S[v]标记已访问(红色节点):queue.pop后,再标记已访问。 priority_queue优先队列:优先处理最短节点。 di 阅读全文
posted @ 2021-03-05 11:29 habibah_chang 阅读(281) 评论(0) 推荐(0) 编辑
摘要: 问题: 给定n个节点,节点到节点所需要耗费的时间,从给定节点k开始, 最少花多长时间遍历完所有节点。 Example 1: Input: times = [[2,1,1],[2,3,1],[3,4,1]], n = 4, k = 2 Output: 2 Example 2: Input: times 阅读全文
posted @ 2021-03-04 17:40 habibah_chang 阅读(58) 评论(0) 推荐(0) 编辑
摘要: 问题: 给定一个由 0 和 1 构成的二维数组。 求每个cell到最近0的距离。 Example 1: Input: [[0,0,0], [0,1,0], [0,0,0]] Output: [[0,0,0], [0,1,0], [0,0,0]] Example 2: Input: [[0,0,0], 阅读全文
posted @ 2021-03-04 15:02 habibah_chang 阅读(57) 评论(0) 推荐(0) 编辑
摘要: 问题: 扫雷问题:给定一个扫雷地图, 包含: M:埋雷cell E:空区cell X:已被挑出的雷cell 1~8:已被扫过的空区cell,该cell四周的埋雷数。 给出扫雷点击坐标click 求,这次click之后的扫雷地图的状态。 变化规则: M:变为X,扫到雷,游戏结束。 E:四周无雷:变为B 阅读全文
posted @ 2021-03-03 18:57 habibah_chang 阅读(43) 评论(0) 推荐(0) 编辑
摘要: 问题: 给定二叉树,求每层最大节点,返回。 Example 1: Input: root = [1,3,2,5,3,null,9] Output: [1,3,9] Example 2: Input: root = [1,2,3] Output: [1,3] Example 3: Input: roo 阅读全文
posted @ 2021-03-03 12:46 habibah_chang 阅读(34) 评论(0) 推荐(0) 编辑
摘要: 问题: 求给定二叉树,最底层最左边的节点值。 Example 1: Input: root = [2,1,3] Output: 1 Example 2: Input: root = [1,2,3,4,null,5,6,null,null,7] Output: 7 Constraints: The n 阅读全文
posted @ 2021-03-03 12:33 habibah_chang 阅读(34) 评论(0) 推荐(0) 编辑
摘要: 问题: 给定一个二维数组,代表一块大陆的海拔, 数组左边和上边为太平洋,右边和下边为大西洋, 对于大陆上的每一个点,有水向海拔=<自己的方向流动,求既能流进太平洋,又能流进大西洋的坐标位置。 Example: Given the following 5x5 matrix: Pacific ~ ~ ~ 阅读全文
posted @ 2021-03-02 17:13 habibah_chang 阅读(43) 评论(0) 推荐(0) 编辑
上一页 1 ··· 7 8 9 10 11 12 13 14 15 ··· 44 下一页