1. Use priority queue. Need to check whether one element has been double counted: 2 Binary search: For this kind of matrix, binary search should work ...
分类:
其他好文 时间:
2017-10-09 14:09:28
阅读次数:
126
Given an index k, return the kth row of the Pascal's triangle. For example, given k = 3,Return [1,3,3,1]. Note:Could you optimize your algorithm to us ...
分类:
其他好文 时间:
2017-10-07 22:09:32
阅读次数:
153
Find the kth largest element in an unsorted array. Note that it is the kth largest element in the sorted order, not the kth distinct element. For exam ...
分类:
其他好文 时间:
2017-10-06 18:04:39
阅读次数:
145
主席树写一发~ 题目大意: 给一个数列,每次询问一个区间内第k小的数. 此题主席树(%Fotile96主席) 代码如下: 不过话说poj一直wa,似乎是空间的锅... ps.HDU也有:HDU2665 ...
分类:
其他好文 时间:
2017-09-30 13:26:26
阅读次数:
147
先吐槽一下,我好气啊,想了很久硬是没有做出来,题目要求的时间复杂度为O(log(m+n)),我猜到了要用二分法,但是没有想到点子上去。然后上网搜了一下答案,感觉好有罪恶感。 题目原型 正确的思路是:把问题转化一下,假设任意给一个k值,求这两个数组合并并按大小排序之后的第k个值。如此一来求中位数只是一... ...
分类:
编程语言 时间:
2017-09-27 16:46:11
阅读次数:
200
堆排序 堆节点的访问 通常堆是通过一维数组来实现的。在数组起始位置为0的情形中: 父节点i的左子节点在位置(2*i+1); 父节点i的右子节点在位置(2*i+2); 子节点i的父节点在位置floor((i-1)/2); 堆的操作 在堆的数据结构中,堆中的最大值总是位于根节点(在优先队列中使用堆的话堆 ...
分类:
编程语言 时间:
2017-09-25 11:30:15
阅读次数:
237
Given an index k, return the kth row of the Pascal's triangle. For example, given k = 3,Return [1,3,3,1]. Note:Could you optimize your algorithm to us ...
分类:
其他好文 时间:
2017-09-23 16:21:33
阅读次数:
122
堆排序做的,没有全部排序,找到第k个就结束 ...
分类:
编程语言 时间:
2017-09-21 22:24:07
阅读次数:
195
原文:背水一战 Windows 10 (50) - 控件(集合类): ItemsControl - 基础知识, 数据绑定, ItemsPresenter, GridViewItemPresenter, ListViewItemPresenter[源码下载] 背水一战 Windows 10 (50) ... ...
题解 我们将图中给出的$VOD$为根建立有根树,每次取出未覆盖的最深的节点第$k$级祖先,将其建为$VOD$,遍历一遍,将能够盖到的点标记。重复,直到盖完。贪心正确性可以证明。 ...
分类:
Web程序 时间:
2017-09-17 15:13:54
阅读次数:
230