验证二叉搜索树。题目即是题意。二叉搜索树的特性是对于每个node而言,他的左子树上任意节点都比他自身小,右子树上任意节点都比他自身大。这个题也是有两种做法,迭代和递归。时间空间复杂度都是O(n)。例子, Example 1: 2 / \ 1 3 Input: [2,1,3] Output: true ...
分类:
其他好文 时间:
2020-01-31 10:43:30
阅读次数:
66
要注意边和节点数是不一样的 # Definition for a binary tree node. # class TreeNode: # def __init__(self, x): # self.val = x # self.left = None # self.right = None cl ...
分类:
其他好文 时间:
2020-01-31 10:21:14
阅读次数:
76
111. Minimum Depth of Binary Tree(二叉树的最小深度) 链接 https://leetcode cn.com/problems/minimum depth of binary tree/ 题目 给定一个二叉树,找出其最小深度。 最小深度是从根节点到最近叶子节点的最短路 ...
分类:
其他好文 时间:
2020-01-30 21:23:30
阅读次数:
55
104. Maximum Depth of Binary Tree(二叉树的最大深度) 链接 https://leetcode cn.com/problems/maximum depth of binary tree 题目 给定一个二叉树,找出其最大深度。 二叉树的深度为根节点到最远叶子节点的最长路 ...
分类:
其他好文 时间:
2020-01-30 21:16:36
阅读次数:
52
965. Univalued Binary Tree(单值二叉树) 链接 https://leetcode cn.com/problems/univalued binary tree 题目 如果二叉树每个节点都具有相同的值,那么该二叉树就是单值二叉树。 只有给定的树是单值二叉树时,才返回?true; ...
分类:
其他好文 时间:
2020-01-30 20:45:03
阅读次数:
57
链接: "LeetCode654" 给定一个不含重复元素的整数数组。一个以此数组构建的最大二叉树定义如下: 二叉树的根是数组中的最大元素。 左子树是通过数组中最大值左边部分构造出的最大二叉树。 右子树是通过数组中最大值右边部分构造出的最大二叉树。 通过给定的数组构建最大二叉树,并且输出这个树的根节点 ...
分类:
其他好文 时间:
2020-01-30 19:12:49
阅读次数:
50
首先遇到这个是因为binlog位置索引处的问题,不要reset slave; reset slave会将主从同步的文件以及位置恢复到初始状态,一开始没有数据还好,有数据的话,相当于重新开始同步,可能会出现一些问题; 一般做主从同步,都是要求以后的数据实现主从同步,而对于旧的数据完全可以使用数据库同步 ...
分类:
其他好文 时间:
2020-01-30 15:51:57
阅读次数:
84
1302. Deepest Leaves Sum Given a binary tree, return the sum of values of its deepest leaves. Example 1: Input: root = [1,2,3,4,5,null,6,7,null,null,n ...
分类:
其他好文 时间:
2020-01-30 12:59:39
阅读次数:
85
{20 01 30 12:03} 今天看到微软的要求,对coding 和算法要求比较多。 [ ] 链表到整数 https://leetcode cn.com/problems/convert binary number in a linked list to integer/ ...
分类:
其他好文 时间:
2020-01-30 12:42:51
阅读次数:
59
Given a binary search tree and a node in it, find the in-order successor of that node in the BST. The successor of a node p is the node with the small ...
分类:
其他好文 时间:
2020-01-30 12:39:54
阅读次数:
54