examination questionsFind the kth largest element in an unsorted array. Note that it is the kth largest element in the sorted order, not the kth disti...
分类:
其他好文 时间:
2015-05-24 21:38:15
阅读次数:
171
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
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
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
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
用递归的方法找到从1到最大的N位整数。
样例
给出 N = 1,
返回[1,2,3,4,5,6,7,8,9].
给出 N = 2,
返回[1,2,3,4,5,6,7,8,9,10,11,...,99].
注意
用下面这种方式去递归其实很容易:
recursion(i) {
if i > largest number:
return...
分类:
其他好文 时间:
2015-05-21 22:43:48
阅读次数:
441
1.Given an array of integers, find a contiguous subarray which has the largest sum.hint: Go through the array with 2 variable -- cur and count. cur i....
分类:
其他好文 时间:
2015-05-21 16:52:25
阅读次数:
107
Patrol RobotTime Limit:3000MSMemory Limit:Unknown64bit IO Format:%lld & %lluSubmitStatusDescriptionA robot has to patrol around a rectangular area whi...
分类:
其他好文 时间:
2015-05-21 06:31:26
阅读次数:
119
For example,Given height = [2,1,5,6,2,3],return 10.解题思路:参考Problem H: Largest Rectangle in a Histogram 第四种思路,或者翻译版Largest Rectangle in Histogram@LeetCo...
分类:
编程语言 时间:
2015-05-19 20:43:54
阅读次数:
174
Given a 2D binary matrix filled with 0's and 1's, find the largest rectangle containing all ones and return its area.解题思路:求01矩阵中,全是1的子矩阵的最大面积。把矩阵按照每一行...
分类:
编程语言 时间:
2015-05-19 20:39:59
阅读次数:
280