码迷,mamicode.com
首页 >  
搜索关键字:treenode    ( 1958个结果
剑指office--------二叉树中和为某一值的路径
题目描述 输入一颗二叉树的根节点和一个整数,按字典序打印出二叉树中结点值的和为输入整数的所有路径。路径定义为从树的根结点开始往下一直到叶结点所经过的结点形成一条路径。 1 /* 2 struct TreeNode { 3 int val; 4 struct TreeNode *left; 5 str ...
分类:其他好文   时间:2020-07-22 20:34:44    阅读次数:68
剑指office--------二叉树的镜像
题目描述 操作给定的二叉树,将其变换为源二叉树的镜像。 输入描述: 二叉树的镜像定义:源二叉树 8 / \ 6 10 / \ / \ 5 7 9 11 镜像二叉树 8 / \ 10 6 / \ / \ 11 9 7 5 1 /* 2 struct TreeNode { 3 int val; 4 st ...
分类:其他好文   时间:2020-07-22 20:33:30    阅读次数:78
leetcode-----99. 恢复二叉搜索树
链接:https://leetcode-cn.com/problems/recover-binary-search-tree/ 代码 /** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode ...
分类:其他好文   时间:2020-07-19 11:36:41    阅读次数:70
leetcode-----100. 相同的树
链接:https://leetcode-cn.com/problems/same-tree/ 代码 /** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode ...
分类:其他好文   时间:2020-07-19 11:33:58    阅读次数:44
[编程题] lc[236. 二叉树的最近公共祖先]
[编程题] lc:236. 二叉树的最近公共祖先 题目描述 输入输出例子 思路 使用后续遍历的思想,根据找到了左和右的情况,进行相应的返回结果。 Java代码 /** * Definition for a binary tree node. * public class TreeNode { * i ...
分类:其他好文   时间:2020-07-19 00:39:06    阅读次数:85
从上到下打印二叉树 III
题解:层次遍历的基础上加个计数器,偶数层得到的结果反转一下 /** * Definition for a binary tree node. * public class TreeNode { * int val; * TreeNode left; * TreeNode right; * TreeN ...
分类:其他好文   时间:2020-07-18 21:52:24    阅读次数:59
从上到下打印二叉树
解题:利用队列先进先出来实现层次遍历 /** * Definition for a binary tree node. * public class TreeNode { * int val; * TreeNode left; * TreeNode right; * TreeNode(int x) ...
分类:其他好文   时间:2020-07-18 19:52:44    阅读次数:68
二叉树的镜像
/** * Definition for a binary tree node. * public class TreeNode { * int val; * TreeNode left; * TreeNode right; * TreeNode(int x) { val = x; } * } */ ...
分类:其他好文   时间:2020-07-18 15:54:16    阅读次数:51
leetcode-----95. 不同的二叉搜索树 II
链接:https://leetcode-cn.com/problems/unique-binary-search-trees-ii/ 代码 /** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNo ...
分类:其他好文   时间:2020-07-18 13:39:30    阅读次数:56
leetcode-----94. 二叉树的中序遍历
链接:https://leetcode-cn.com/problems/binary-tree-inorder-traversal/ 代码 /** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNo ...
分类:其他好文   时间:2020-07-18 11:34:31    阅读次数:66
1958条   上一页 1 ... 10 11 12 13 14 ... 196 下一页
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!