题目描述 给定一个二叉树,计算整个树的坡度。 一个树的节点的坡度定义即为,该节点左子树的结点之和和右子树结点之和的差的绝对值。空结点的的坡度是0。 整个树的坡度就是其所有节点的坡度之和。 示例: 题目链接: https://leetcode cn.com/problems/binary tree t ...
分类:
其他好文 时间:
2020-04-17 12:40:30
阅读次数:
57
A.Binary Tree Traversals(二叉树) 题意: 给出一颗二叉树的先序和中序,求后序 题解: 递归建树,细节不表。 #include<cstdio> #include<algorithm> #include<cstring> using namespace std; const i ...
分类:
其他好文 时间:
2020-04-16 20:57:57
阅读次数:
66
[TOC] 文中主要监控MySQL/MySQL主从信息 版本:mysql 5.7,mysql_exporter 0.12.1 "mysql_exporter下载地址" 1、mysql_exporter部署 1.下载mysql_exporter并解压 2.需要授权用户给exporter使用 为该用户设 ...
分类:
数据库 时间:
2020-04-16 19:27:49
阅读次数:
103
import java.util.* class Solution { fun minDepth(root: TreeNode?): Int { if (root == null) { return 0 } var depth = 0 //LinkedList实现了Queue接口,可以用作队列使用 ...
分类:
其他好文 时间:
2020-04-16 15:12:48
阅读次数:
56
Given a binary tree, return the values of its boundary in anti-clockwise direction starting from root. Boundary includes left boundary, leaves, and ri ...
分类:
其他好文 时间:
2020-04-15 21:10:31
阅读次数:
65
传送门:https://leetcode-cn.com/problems/lowest-common-ancestor-of-a-binary-tree/ 给定一个二叉树, 找到该树中两个指定节点的最近公共祖先。 百度百科中最近公共祖先的定义为:“对于有根树 T 的两个结点 p、q,最近公共祖先表示 ...
分类:
其他好文 时间:
2020-04-15 18:10:47
阅读次数:
71
Given two binary trees original and cloned and given a reference to a node target in the original tree. The cloned tree is a copy of the original tree ...
分类:
其他好文 时间:
2020-04-15 09:14:36
阅读次数:
74
The lowest common ancestor (LCA) of two nodes U and V in a tree is the deepest node that has both U and V as descendants. A binary search tree (BST) i ...
分类:
其他好文 时间:
2020-04-14 18:37:40
阅读次数:
59
二、二叉树 在进一步讨论树之前,先讨论一种简单而重要的树结构——二叉树。因为 任何树都可以转化为二叉树进行处理,二叉树作为特殊的树,适合于计算机处理 ,所以二叉树是研究的重点。 1. 二叉树的基本操作 1. 定义: 定义:把满足以下两个条件的树型结构叫做二叉树( Binary Tree): ? (1 ...
分类:
其他好文 时间:
2020-04-12 22:24:39
阅读次数:
100
MySQL优化-索引 二分查找 拆半查找,binary search 一种在有序数组中查找某一特定元素的搜索算法。 二分查找法的优点是比较次数少,查找速度快,平均性能好;其缺点是要求待查表为有序表,且插入删除困难。因此,二分查找方法适用于不经常变动而查找频繁的有序列表。 二叉树 二叉树的每个节点至多 ...
分类:
数据库 时间:
2020-04-12 20:36:38
阅读次数:
91