牛客题霸--寻找第K大
寻找第K大
https://www.nowcoder.com/practice/e016ad9b7f0b45048c58a9f27ba618bf?tpId=117&&tqId=35010&rp=1&ru=/ta/job-code-high&qru=/ta/job-code-high/question-ranking
做法:排序
时间复杂度:
思路:
这题所要求输入n个整数,找出其中第k大的数.
时间复杂度:
思路:
这题所要求输入n个整数,找出其中第k大的数.
代码:
class Finder { public: int findKth(vector<int> a, int n, int K) { // write code here sort(a.rbegin(), a.rend()); return a[K-1]; } };