树上启发式合并/dsu on tree 前置芝士 启发式合并和树链剖分的部分知识。(不会的去这里搜) 因为要在一颗树上进行启发式合并,所以要找最优的方法,即优雅的暴力(雾 它可以让 \(O(n^2)\) 变为 \(O(n\log n)\) (证明 你就想想启发式合并就完了) 概念 树上启发式合并(d ...
分类:
其他好文 时间:
2020-07-19 17:59:35
阅读次数:
75
#树状数组 又名二叉索引树,是一种与线段树相似的数据结构 他们能使对一个区间的数修改以及查询的速度提升许多 ##树状数组模板1 #include<iostream> #include<cstdio> using namespace std; int tree[2333333]; int sum[23 ...
分类:
其他好文 时间:
2020-07-19 16:06:22
阅读次数:
52
链接: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
链接: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. 二叉树的最近公共祖先 题目描述 输入输出例子 思路 使用后续遍历的思想,根据找到了左和右的情况,进行相应的返回结果。 Java代码 /** * Definition for a binary tree node. * public class TreeNode { * i ...
分类:
其他好文 时间:
2020-07-19 00:39:06
阅读次数:
85
struct BinaryTreeNode { int nvalue=0; BinaryTreeNode* pleft = nullptr; BinaryTreeNode* pright = nullptr; BinaryTreeNode* parent = nullptr;};vector<vec ...
分类:
其他好文 时间:
2020-07-18 22:37:14
阅读次数:
87
题解:层次遍历的基础上加个计数器,偶数层得到的结果反转一下 /** * 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