题解:层次遍历的基础上加个计数器,偶数层得到的结果反转一下 /** * 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
MySQL源码关于链表的实现在ut0lst.h文件中,其设计思路与常规略有不同,基本思想是指针嵌于对象之内,如下图所示。 在这种实现方式下,构造一个链表需要同时指定对象类型和对象内指针节点的地址。为什么这么复杂呢?我们对比一下C++11标准库中list的实现,发现其就是一个模板类,构造一个list只 ...
分类:
数据库 时间:
2020-07-18 19:51:54
阅读次数:
75
/** * 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
本文中案例都会在上传到git上,请放心浏览 git地址:https://github.com/muxiaonong/Spring-Cloud/tree/master/order-lock 本文会使用到 三台 redis 独立服务器,可以自行提前搭建好 前言 在Java中,我们对于锁会比较熟悉,常用的 ...
分类:
其他好文 时间:
2020-07-18 15:49:42
阅读次数:
60
kyu8--fake binary 将小于5的数字用0掩码,大于等于5的用1掩码,用string 下面的答案是高赞的答案。return s.translate(string.maketrans('0123456789', '0000011111')) ...
分类:
其他好文 时间:
2020-07-18 13:46:35
阅读次数:
64
链接: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
链接: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
A - Distance in Tree CodeForces - 161D 题目大意:树是一个不包含任何圈的连通图。树的两个节点之间的距离是节点之间最短路径的长度(也就是边的长度)。 给定一棵有n个节点的树和一个正整数k,找出距离恰好为k的不同节点对的数量。注意,节点对(v, u)和节点对(u, ...
分类:
其他好文 时间:
2020-07-18 11:28:18
阅读次数:
57
链接:https://leetcode-cn.com/problems/unique-binary-search-trees/ 代码 class Solution { public: int numTrees(int n) { vector<int> f(n + 1); f[0] = 1; for ...
分类:
其他好文 时间:
2020-07-18 11:25:21
阅读次数:
56