/** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val(x), left(NULL), r ...
分类:
其他好文 时间:
2020-07-17 13:55:38
阅读次数:
71
/** * Definition for a binary tree node. * public class TreeNode { * int val; * TreeNode left; * TreeNode right; * TreeNode() {} * TreeNode(int val) { ...
分类:
其他好文 时间:
2020-07-16 00:01:06
阅读次数:
61
题目描述链接:https://leetcode-cn.com/problems/search-in-a-binary-search-tree/ 基本思路:等于返回,当前节点值大于搜索值从左子树搜索,小于从右子树搜索。以此可以用递归或迭代法实现,下面分别展示两种方法; (1)采用递归的方法 LeetC ...
分类:
其他好文 时间:
2020-07-15 23:43:11
阅读次数:
76
/** * Definition for a binary tree node. * public class TreeNode { * int val; * TreeNode left; * TreeNode right; * TreeNode(int x) { val = x; } * } */ ...
分类:
其他好文 时间:
2020-07-15 23:40:01
阅读次数:
70
/** * Definition for a binary tree node. * public class TreeNode { * int val; * TreeNode left; * TreeNode right; * TreeNode(int x) { val = x; } * } */ ...
分类:
其他好文 时间:
2020-07-15 23:31:48
阅读次数:
66
96. 不同的二叉搜索树 题目来源:力扣(LeetCode)https://leetcode-cn.com/problems/unique-binary-search-trees 题目 给定一个整数 n,求以 1 ... n 为节点组成的二叉搜索树有多少种? 示例: 输入: 3 输出: 5 解释: ...
分类:
编程语言 时间:
2020-07-15 23:11:39
阅读次数:
74
(熟练!重要!)二叉搜索树 BST ##题目大意 判断给定序列是否是一个BST或镜像BST树的先序遍历序列,如果是则输出该树的后序遍历序列。 ##思路 根据给定序列创建BST树,求出它的先序遍历和镜像树的先序遍历(即原树遍历时按照根->右->左),与原序列比较。 ##AC代码 #define _CR ...
分类:
其他好文 时间:
2020-07-14 11:52:38
阅读次数:
62
题目链接 https://leetcode-cn.com/problems/binary-tree-inorder-traversal/ 题解一:递归 // Problem: LeetCode 94 // URL: https://leetcode-cn.com/problems/binary-tr ...
分类:
其他好文 时间:
2020-07-13 15:36:49
阅读次数:
58
Given a binary string s (a string consisting only of '0' and '1's). Return the number of substrings with all characters 1's. Since the answer may be t ...
分类:
其他好文 时间:
2020-07-13 09:56:37
阅读次数:
68
Given a binary string s (a string consisting only of '0' and '1's). Return the number of substrings with all characters 1's. Since the answer may be t ...
分类:
其他好文 时间:
2020-07-13 09:45:45
阅读次数:
61