码迷,mamicode.com
首页 >  
搜索关键字:kth    ( 692个结果
Java for LeetCode 118 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].解题思路:注意,本题的k相当于上题的k+1,其他照搬即可,JAVA实现如下: pub...
分类:编程语言   时间:2015-05-24 17:21:09    阅读次数:174
Kth Largest Element in an Array
class Solution {public: int findKthLargest(vector& nums, int k) { int index=0; int backindex = nums.size()-1, forindex = 0; while(1)...
分类:其他好文   时间:2015-05-24 16:58:15    阅读次数:145
Kth Largest Element in an Array
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 example, Given [3,2,1,5,6,4] and k = 2, return 5. ...
分类:其他好文   时间:2015-05-23 18:25:13    阅读次数:131
[LeetCode]Kth Largest Element in an Array
https://leetcode.com/problems/kth-largest-element-in-an-array/Kth Largest Element in an ArrayFind thekth largest element in an unsorted array. Note th...
分类:其他好文   时间:2015-05-23 18:21:33    阅读次数:106
[LeetCode] Kth Largest Element in an Array
Find thekth largest element in an unsorted array.For example,Given[3,2,1,5,6,4]and k = 2, return 5.Note:You may assume k is always valid, 1 ≤ k ≤ arra...
分类:其他好文   时间:2015-05-23 12:50:52    阅读次数:134
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? 从后往前计算 //用一个数组滚...
分类:其他好文   时间:2015-05-19 22:39:04    阅读次数:151
Pascal's Triangle II -- leetcode
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? 基本思路: 内层循环,使用...
分类:其他好文   时间:2015-05-17 16:51:36    阅读次数:111
[LeetCode] Pascal's Triangle II
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) ex...
分类:其他好文   时间:2015-05-12 15:45:55    阅读次数:143
HDU ACM 4006 The kth great number 线段树?优先队列?
分析:可以用线段树做,但感觉麻烦。用优先队列,每次插入时都保留前k个大的数即可。 #include #include #include using namespace std; int main() { int n,k,j,c; char b[2]; ios::sync_with_stdio(false); while(cin>>n>>k) { priority_queue,g...
分类:其他好文   时间:2015-05-10 15:49:40    阅读次数:118
leetcode || 119、Pascal's Triangle II
problem: 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 spac...
分类:其他好文   时间:2015-04-24 12:40:14    阅读次数:151
692条   上一页 1 ... 60 61 62 63 64 ... 70 下一页
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!