题解 | #查找第K小数#

查找第K小数

https://www.nowcoder.com/practice/204dfa6fcbc8478f993d23f693189ffd

#include <bits/stdc++.h>
using namespace std;

int main() {
    int n;cin>>n;
    set<int>s;
    while(n--){
        int temp;cin>>temp;
        s.insert(temp);
    }
    int k;cin>>k;
    int c=0;
    for(auto a:s){
        c++;
        if(c == k){
            cout<<a<<endl;
            break;
        }
    }
        

}
// 64 位输出请用 printf("%lld")

qd

全部评论

相关推荐

LZStarV:冲就好了,就算真的是字节也冲,面评脏了大不了等三四个月就淡了,而且等到那个时候实力进步了选择还多,何必拘泥于字节
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务