国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁(yè) > 編程 > C++ > 正文

C++算法題_第二周

2019-11-06 07:29:40
字體:
來(lái)源:轉(zhuǎn)載
供稿:網(wǎng)友

題目來(lái)源      點(diǎn)擊打開(kāi)鏈接

題目詳情    

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.

Note: 

You may assume k is always valid, 1 ≤ k ≤ array's length.

Credits:

Special thanks to @mithmatt for adding this PRoblem and creating all test cases

Subscribe to see which companies asked this question.

題目解答     
class Solution {public:    int findKthLargest(vector<int>& nums, int k) {        sort(nums.begin(),nums.end());        return nums[nums.size() - k];    }};
發(fā)表評(píng)論 共有條評(píng)論
用戶(hù)名: 密碼:
驗(yàn)證碼: 匿名發(fā)表

圖片精選

主站蜘蛛池模板: 屏边| 浏阳市| 阜南县| 崇州市| 虎林市| 交口县| 平顶山市| 丹东市| 房产| 三明市| 陇南市| 台前县| 周至县| 濮阳市| 沛县| 石台县| 五原县| 平陆县| 满洲里市| 霍林郭勒市| 苏尼特右旗| 营山县| 绍兴县| 辛集市| 渝中区| 温州市| 同仁县| 宁强县| 邢台市| 壶关县| 霞浦县| 泽州县| 宁南县| 晴隆县| 白玉县| 巴彦县| 牟定县| 肃宁县| 马鞍山市| 延津县| 鹤庆县|