码迷,mamicode.com
首页 >  
搜索关键字:easyui treegrid treenode    ( 5856个结果
二叉树最近公共祖先
思路:后序遍历, 分情况讨论: 1、两个节点在根的左侧 2、两个节点在根的右侧 3、两个节点在根的左右两侧 /** * Definition for a binary tree node. * public class TreeNode { * int val; * TreeNode left; * ...
分类:其他好文   时间:2020-07-23 22:15:14    阅读次数:77
LC1008 Construct Binary Search Tree from Preorder Traversal
根据BST的前序遍历重建BST 1. 平均O(NlogN) 最坏O(N^2) class Solution { public: TreeNode* dfs(int l, int r, vector<int>& p) { if (l > r) return nullptr; TreeNode* nod ...
分类:其他好文   时间:2020-07-23 16:13:09    阅读次数:67
剑指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
5856条   上一页 1 ... 11 12 13 14 15 ... 586 下一页
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!