摘要: 原题链接 题解 题目是说有多少个连通块,每一次以一个开始,遍历并标记他能够到达的点(就是同一个连通块中的点) 代码如下 dfs #include <iostream> #include <algorithm> #include <cmath> #include <cstring> #include 阅读全文
posted @ 2020-07-04 15:34 Lngstart 阅读(90) 评论(0) 推荐(0)
摘要: 原题链接 题解 一个三维的bfs,直接向6个方向走就是了,直接套模板 #include <iostream> #include <algorithm> #include <queue> using namespace std; typedef struct node{ int x, y, z; no 阅读全文
posted @ 2020-07-04 14:44 Lngstart 阅读(190) 评论(0) 推荐(0)
摘要: 原题链接 题解 二叉搜索树的中序遍历是升序序列,题目给定的数组是按照升序的有序数组,因此可以确保数组是二叉搜索树的中序遍历序列。 题目中要保证是平衡的二叉搜索树,所以我们只要每次选择数组区间中间的点作为节点,节点的左边的数字一定是该节点的左子树,同理右边也是,就能保证是一个平衡的二叉树,利用递归来实 阅读全文
posted @ 2020-07-04 13:38 Lngstart 阅读(96) 评论(0) 推荐(0)