Leetcode Tree Depth-first Search Given preorder and inorder traversal of a tree, construct... ...
分类:
其他好文 时间:
2019-10-02 21:08:04
阅读次数:
100
题意:给出头结点,让你判断这颗树是不是二叉搜索树。 思路: 很显然,对于一棵二叉搜索树,其左右子树肯定也是二叉搜索树; 因此,递归思路:如果左右子树都是BST,并且该根结点也符合规律(小于左子树的最小结点,小于右子树的最大结点) 递归边界:如果是空节点,那么返回true; 我在实现的时候偷了一点懒; ...
分类:
其他好文 时间:
2019-10-02 21:05:09
阅读次数:
131
111. Minimum Depth of Binary Tree Easy Easy Easy Given a binary tree, find its minimum depth. The minimum depth is the number of nodes along the short ...
分类:
其他好文 时间:
2019-10-02 17:02:53
阅读次数:
77
输入:一个已经排好序的待搜索数组array_to_search,需要查找的数number,查找边界left、right。 输出:number在array_to_search中的位置,若未找到,输出 1。 实现思路 1. 将数组的中间元素array_to_search[middle]与待查找数numb ...
分类:
其他好文 时间:
2019-10-02 11:01:45
阅读次数:
89
110. Balanced Binary Tree Easy Easy Easy Given a binary tree, determine if it is height-balanced. For this problem, a height-balanced binary tree is d ...
分类:
其他好文 时间:
2019-10-02 10:23:19
阅读次数:
88
fasffasfa 108. Convert Sorted Array to Binary Search Tree Easy Easy Easy Given an array where elements are sorted in ascending order, convert it to a ...
分类:
其他好文 时间:
2019-10-01 18:54:01
阅读次数:
108
107. Binary Tree Level Order Traversal II Easy Easy Easy Given a binary tree, return the bottom-up level order traversal of its nodes' values. (ie, fr ...
分类:
其他好文 时间:
2019-10-01 12:19:17
阅读次数:
104
题意:给定一个数n,求出1~n,所有二叉树的个数; 在LeetCode 95中,要你求出所有二叉树,并返回结点,题解见:https://www.cnblogs.com/yy-1046741080/p/11594454.html。 原来我就想用直接递归,来求出结点个数的,结果发现TE; 在近期了解了D ...
分类:
其他好文 时间:
2019-09-30 20:05:16
阅读次数:
72
1. 冒泡排序 2. 插入排序 3. 选择排序 4. 快速排序 5. 二分查找 ...
分类:
编程语言 时间:
2019-09-30 17:01:02
阅读次数:
91
104. Maximum Depth of Binary Tree Easy Easy Easy Given a binary tree, find its maximum depth. The maximum depth is the number of nodes along the longe ...
分类:
其他好文 时间:
2019-09-29 15:39:53
阅读次数:
112