给定一棵二叉树,想象自己站在它的右侧,按照从顶部到底部的顺序,返回从右侧所能看到的节点值。示例:输入: [1,2,3,null,5,null,4]输出: [1, 3, 4]解释: 1 rightSideView(TreeNode* root) { vector ans; if(root==NULL)... ...
分类:
其他好文 时间:
2020-04-22 09:54:24
阅读次数:
52
题目描述 Given an array nums, there is a sliding window of size k which is moving from the very left of the array to the very right. You can only see the ...
题目: 考察点: 差分数组,思维。 分析: Code: ...
分类:
其他好文 时间:
2020-04-20 23:53:02
阅读次数:
115
1.树状数组:题目:UVA1428 1 #include<iostream> 2 #include<algorithm> 3 #include<cstdio> 4 #include<string> 5 #include<cstring> 6 #include<numeric> 7 #include< ...
分类:
其他好文 时间:
2020-04-18 20:11:25
阅读次数:
110
Problem : You are given n pairs of numbers. In every pair, the first number is always smaller than the second number. Now, we define a pair (c, d) can ...
分类:
其他好文 时间:
2020-04-18 10:09:19
阅读次数:
67
先给出哈夫曼树的定义:构造一颗包含n个节点的k叉树其中每个叶子节点都有权值w[i],要求最小化所有叶子节点的w[i]*deep[i]之和.该问题的解被称为k叉哈夫曼树. 先来说两个引理: 1.权值最小的节点深度必定最大. 证明:我们设x,y.使得w[x]>w[y].但deep[x]>deep[y]如 ...
分类:
其他好文 时间:
2020-04-16 20:55:30
阅读次数:
89
这道题大可看成贪心来做。 根据题目所说,物品重量无非两种,要么重量是 1 ,要么重量是 2 ,那么按物品重量把它们分成两类,用一个 $pair$ 来存物品的价值和序号(因为输出要用),按价值对两个物品序列降序排序。 然后枚举用 $i$ 个重量为 1 的物品(理论上 2 也可以),那么就用了 $\fr ...
分类:
其他好文 时间:
2020-04-16 13:18:58
阅读次数:
48
Chinese(Simplified) Language Pack for Visual Stidio Code 中文汉化包 Bracket Pair Colorizer 用不同颜色高亮显示匹配的括号 Auto Rename Tag 尾部闭合标签同步修改 Auto Close Tag 自动闭合标签 ...
分类:
其他好文 时间:
2020-04-14 15:12:29
阅读次数:
66
``` #include #define f first #define s second using namespace std; typedef long long ll; const int N=300005; typedef pair P; int n,tot,t,V; map mp; ma... ...
分类:
其他好文 时间:
2020-04-12 18:18:38
阅读次数:
100