摘要: ##题目链接 https://leetcode-cn.com/problems/validate-binary-search-tree/ ##个人题解 ###解法1 ####思路 根据二叉搜索树定义,左子树值均小于根,右子树值均大于根。由此便想到自下而上维护每个子树中最大最小值,确保树根左子树最大值 阅读全文
posted @ 2021-01-08 19:23 deepwzh 阅读(75) 评论(0) 推荐(0) 编辑
摘要: ##深度优先搜索 ###专题页 https://leetcode-cn.com/tag/depth-first-search/ ###题解记录 111. 二叉树的最小深度 难度:简单 98. 验证二叉搜索树 难度:中等 阅读全文
posted @ 2021-01-08 17:05 deepwzh 阅读(39) 评论(0) 推荐(0) 编辑
摘要: ##题目链接 https://leetcode-cn.com/problems/minimum-depth-of-binary-tree/ ##个人题解 class Solution { private: int min_h; void dfs(TreeNode * root, int h){ if 阅读全文
posted @ 2021-01-08 17:02 deepwzh 阅读(58) 评论(0) 推荐(0) 编辑
摘要: ##题目链接 https://leetcode-cn.com/problems/leaf-similar-trees/ ##个人实现: #include <vector> class Solution { private: void dfs(TreeNode * root, vector<int> 阅读全文
posted @ 2021-01-08 16:53 deepwzh 阅读(51) 评论(0) 推荐(0) 编辑
摘要: 最近开始写Leetcode的每日一题,以后会将个人解法发布在这里。目前打算尽量用多种语言,多种方法来完成这些题目。 2020.1 2020.1.7 547. 省份数量 难度:中等 待更新 2020.1.8 189. 旋转数组 难度:中等 https://www.cnblogs.com/Wade-/p 阅读全文
posted @ 2021-01-08 10:05 deepwzh 阅读(61) 评论(0) 推荐(0) 编辑
摘要: ##个人题解1:python,一行流,时间复杂度O(n),空间复杂度O(n) ###完整代码: class Solution: def rotate(self, nums: List[int], k: int) -> None: nums[:] = (nums + nums)[len(nums)-k 阅读全文
posted @ 2021-01-08 10:03 deepwzh 阅读(88) 评论(0) 推荐(0) 编辑