码迷,mamicode.com
首页 >  
搜索关键字:treenode    ( 1958个结果
从零开始手写缓存框架 redis(13)HashMap 源码原理详解
为什么学习HashMap源码?作为一名java开发,基本上最常用的数据结构就是HashMap和List,jdk的HashMap设计还是非常值得深入学习的。无论是在面试还是工作中,知道原理都对会我们有很大的帮助。本篇的内容较长,建议先收藏,再细细品味。不同于网上简单的源码分析,更多的是实现背后的设计思想。涉及的内容比较广泛,从统计学中的泊松分布,到计算机基础的位运算,经典的红黑树、链表、数组等数据结
分类:其他好文   时间:2020-11-12 13:38:48    阅读次数:8
LeetCode:236 二叉树的最近公共祖先
class Solution { private TreeNode res = null; public boolean dfs(TreeNode root,TreeNode p,TreeNode q){ if(root==null){ return false; } boolean lchild ...
分类:其他好文   时间:2020-11-11 16:27:40    阅读次数:8
Leetcode1382.将二叉搜索树变平衡
题目 代码 /** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val(x), left(NU ...
分类:其他好文   时间:2020-11-10 10:47:27    阅读次数:5
Leetcode 对称二叉树
Leetcode 101 数据结构定义: /** * Definition for a binary tree node. * public class TreeNode { * int val; * TreeNode left; * TreeNode right; * TreeNode(int x ...
分类:其他好文   时间:2020-11-07 16:16:53    阅读次数:21
JS实现平衡二叉树
1 class TreeNode { 2 constructor(key) { 3 this.key = key; 4 this.leftChild = null; 5 this.rightChild = null; 6 this.parent = null; 7 } 8 rightRotate() ...
分类:Web程序   时间:2020-11-06 02:45:04    阅读次数:36
Leetcode 104. 二叉树的最大深度
题解:递归求左右子树的最大深度。 /** * Definition for a binary tree node. * public class TreeNode { * int val; * TreeNode left; * TreeNode right; * TreeNode(int x) { ...
分类:其他好文   时间:2020-11-06 01:10:43    阅读次数:21
剑指 Offer 32 - II. 从上到下打印二叉树 II
思路 方法一:辅助队列保存对应层数 我们可以用广度优先搜索解决这个问题。 我们可以想到最朴素的方法是用一个二元组 (node, level) 来表示状态,它表示某个节点和它所在的层数,每个新进队列的节点的 level 值都是父亲节点的 level 值加一。 最后根据每个点的 level 对点进行分类 ...
分类:其他好文   时间:2020-11-01 21:30:46    阅读次数:22
求根到叶子节点数字之和
##前序遍历+判断 /** * Definition for a binary tree node. * public class TreeNode { * int val; * TreeNode left; * TreeNode right; * TreeNode(int x) { val = x ...
分类:其他好文   时间:2020-10-30 11:39:04    阅读次数:14
LeetCode 145. 二叉树的后序遍历
class Solution { public List<Integer> postorderTraversal(TreeNode root) { //一般解法,前序遍历后,翻转下结果集,注意下 与前序遍历的进栈顺序不一样 //(前序) 根左右 --> 变为 根右左 --> 翻转 左右根 (后续) ...
分类:其他好文   时间:2020-10-27 11:40:04    阅读次数:20
Leetcode 95 Unique Binary Search Trees II
题目介绍 给定正整数n,利用1到n构造所有可能的二叉树,并返回。 Example: Input: 3 Output: [ [1,null,3,2], [3,2,null,1], [3,1,null,null,2], [2,1,3], [1,null,2,null,3] ] Explanation: ...
分类:其他好文   时间:2020-10-26 11:19:06    阅读次数:17
1958条   上一页 1 ... 5 6 7 8 9 ... 196 下一页
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!