题解 | 查找第K小数

查找第K小数

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

#include<iostream>
#include<set>
using namespace std;
 
int main(){
    int n;
    cin>>n;
    set<int>que;
    while(n--){
        int p;
        cin>>p;
        que.insert(p);
    }
    int i;
    cin>>i;
    for(auto p:que){
        i--;
        if(i==0){
            cout<<p<<endl;
            break;
        }
    }
    
}

全部评论

相关推荐

评论
点赞
收藏
分享

创作者周榜

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