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-08-20 18:58:12
阅读次数:
157
C语言版double find_kth(int* nums1, int nums1Size, int* nums2, int nums2Size, int k, int c) { if (0 == nums1Size) { if (0 == c) return nums2[k -...
分类:
其他好文 时间:
2015-08-19 22:56:13
阅读次数:
108
The kth great number
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65768/65768 K (Java/Others)
Total Submission(s): 8622 Accepted Submission(s): 3399
Problem Description
Xiao ...
分类:
其他好文 时间:
2015-08-18 16:19:29
阅读次数:
174
题目大意:给出一棵树,3种操作
DIST u,v 询问u到v的距离
KTH k, u, v 询问u到v的路径上的第k大的边的权值解题思路:刚开始以为会爆,结果发现不会
直接暴力存储u到v的路上的所有边,再进行排序,输出第k大的边即可#include
#include #define N 10010struct Edge{
int to, next...
分类:
其他好文 时间:
2015-08-18 01:15:27
阅读次数:
117
题意:给定一列数,每次查询区间[s,t]中的第k大;参考:http://www.cnblogs.com/kane0526/archive/2013/04/20/3033212.html http://www.cnblogs.com/kuangbin/archive/2012/08/14/2638.....
分类:
其他好文 时间:
2015-08-16 07:03:07
阅读次数:
171
1、题目名称 Pascal‘s Triangle II(帕斯卡三角形2) 2、题目地址 https://leetcode.com/problems/pascals-triangle-ii/ 3、题目内容 英文:Given an index k, return the kth row of the Pascal‘s triangle. 中文...
分类:
其他好文 时间:
2015-08-15 16:45:00
阅读次数:
155
Given a binary search tree, write a functionkthSmallestto find thekth smallest element in it.Note:You may assume k is always valid, 1 ≤ k ≤ BST's tota...
分类:
其他好文 时间:
2015-08-14 16:58:03
阅读次数:
98
Find thekth largest element in an unsorted array. Note that it is the kth largest element in the sorted order, not the kth distinct element.For exampl...
分类:
其他好文 时间:
2015-08-13 11:23:41
阅读次数:
108
【119-Pascal’s Triangle II(帕斯卡三角形II)】【LeetCode-面试算法经典-Java实现】【所有题目目录索引】原题 Given an index k, return the kth row of the Pascal’s triangle.
For example, given k = 3,
Return [1,3,3,1].
Note:
Co...
分类:
编程语言 时间:
2015-08-13 07:48:37
阅读次数:
176
这个题目使用快排。这里涉及如何实现快排的问题。在[1]当中有一个快排的实现例子。在这里我们关注与快排的实现而不是这个问题本身,因为快排的问题解决了,这个问题就解决了快排的思想是选择一个元素,从两边进行遍历将遇到的第一对不满足序列关系的元素进行交换。关键是这里如何实现这种兑换1、可以在同时找到这两个元...
分类:
其他好文 时间:
2015-08-11 20:53:54
阅读次数:
83