怕是还没有题解,所以先写一篇。 这题就是维护带修改的主席树。首先树套树肯定是能做的,既然树套树能做那么整体二分肯定也是可以的。 由于我并没有使用这两种做法,所以此处不予介绍。 大概描述下主席树的思路: 首先说说怎么搞带修改主席树? 回忆一般的kth问题,我们的主席树求的是前缀和,这样我们在目标区间的 ...
分类:
编程语言 时间:
2019-01-20 12:06:30
阅读次数:
208
703 非常经典的一个题,假设有一个不断增加的序列,要求输出第K 大的数 215 太简单了,就不说了。 ...
分类:
其他好文 时间:
2019-01-15 10:45:42
阅读次数:
231
Given a non-negative index k where k ≤ 33, return the kth index row of the Pascal's triangle. Note that the row index starts from 0. In Pascal's trian ...
分类:
其他好文 时间:
2019-01-11 14:19:58
阅读次数:
189
题目描述 输入一个链表,输出该链表中倒数第k个结点。 题目解答 方法一: /* public class ListNode { int val; ListNode next = null; ListNode(int val) { this.val = val; } }*/ public class ...
分类:
其他好文 时间:
2018-12-19 23:25:39
阅读次数:
277
在无序的数组中找到第k大的元素,也就是若长度为n的数组从小到大排列时,下标为n-k的元素。 注意Example2:第4大的元素是4,也就是数组中出现的两个5分别是第2大和第3大的数字。 解法一:直接将数组从大到小排序,取出下标为n-k的元素。 解法二: ...
分类:
其他好文 时间:
2018-12-17 22:01:27
阅读次数:
219
思路
splay区间操作的裸题。
假如要对l-r这段区间操作,那么就先把l-1伸展到根节点,然后把r +1伸展为根的儿子。这样r + 1的左儿子就是要操作的区间了。只要在上面打上标记,以后每次查询的时候pushdown一下。 ...
分类:
其他好文 时间:
2018-12-09 13:58:19
阅读次数:
205
703. Kth Largest Element in a Stream Easy Easy Design a class to find the kth largest element in a stream. Note that it is the kth largest element in ...
分类:
其他好文 时间:
2018-12-09 13:51:29
阅读次数:
159
Given a non-negative index k where k ≤ 33, return the kth index row of the Pascal's triangle. Note that the row index starts from 0. In Pascal's trian ...
分类:
其他好文 时间:
2018-12-02 19:22:23
阅读次数:
149
Design a class to find the kth largest element in a stream. Note that it is the kth largest element in the sorted order, not the kth distinct element. ...
分类:
其他好文 时间:
2018-11-25 00:04:01
阅读次数:
150
https://leetcode.com/problems/kth-largest-element-in-a-stream/description/ ...
分类:
其他好文 时间:
2018-11-18 15:07:25
阅读次数:
100