码迷,mamicode.com
首页 >  
搜索关键字:kth    ( 692个结果
2.2 Kth element linked list
ProblemImplement an algorithm to find the kth to last element of a singly linked list.Solution 1 public static ListNode findElement(ListNode head, int...
分类:其他好文   时间:2014-11-22 10:38:33    阅读次数:168
飘逸的python - 大数据TopK问题的quick select解法
TopK问题,即寻找最大的K个数,这个问题非常常见,比如从1千万搜索记录中找出最热门的10个关键词. 方法一: 先排序,然后截取前k个数. 时间复杂度:O(n*logn)+O(k)=O(n*logn)。 方法二: 最小堆. 维护容量为k的最小堆.根据最小堆性质,堆顶一定是最小的,如果小于堆顶,则直接pass,如果大于堆顶,则替换掉堆顶,并heapify整理堆,其中heapify...
分类:编程语言   时间:2014-11-21 18:42:10    阅读次数:225
HDU2665 Kth number 【归并树】
Kth number Time Limit: 15000/5000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 5425    Accepted Submission(s): 1760 Problem Description Give you a seq...
分类:其他好文   时间:2014-11-12 17:51:37    阅读次数:200
[leetcode] 2. Pascal's Triangle II
我是按难度往下刷的,第二道是帕斯卡三角形二。简单易懂,题目如下: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 y...
分类:其他好文   时间:2014-11-11 01:58:05    阅读次数:242
Leetcode-Pascal's Triangle II
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 use...
分类:其他好文   时间:2014-11-08 10:26:18    阅读次数:173
poj 1442 名次树
这回要求的是第k小的元素,参考了ljl大神的模板,orz 1 //insert 插入 2 //remove 删除 3 //_find 查找 4 //kth 返回root为根的树中第k小的元素 5 //treap插入、删除、查询时间复杂度均为O(logn) 6 #include 7 #...
分类:其他好文   时间:2014-10-28 19:55:27    阅读次数:283
hdu 4006 The kth great number (优先队列)
优先队列头文件#include 默认优先为从大到小优先。自定义优先级 1 struct cmpmin{ //按从小到大 2 3 // 因为标准库默认使用元素类型的b; //所以规定小的元素...
分类:其他好文   时间:2014-10-28 00:24:09    阅读次数:243
Pascal's Triangle II
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 use...
分类:其他好文   时间:2014-10-27 17:33:44    阅读次数:223
[leetcode]Pascal's Triangle II
问题描述: 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 use only O(k) extra space? 思路: ...
分类:其他好文   时间:2014-10-26 11:46:08    阅读次数:251
Treap实现山寨set
treap插入、删除、查询时间复杂度均为O(logn)treap树中每个节点有两种权值:键值和该节点优先值如果只看优先值,这棵树又是一个堆treap有两种平衡方法:左旋&右旋insert 插入remove 删除_find 查找kth 返回root为根的树中第k大的元素 1 #include 2...
分类:其他好文   时间:2014-10-16 00:52:11    阅读次数:274
692条   上一页 1 ... 64 65 66 67 68 ... 70 下一页
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!