Update appNew update is available. Click here to update.
About
Indian Institute of Information Technology, Pune 2026
C++ - Default language
My Stats
EXP gained
yellow-spark
3598
Level
5 (Champion)
Community stats
Discussions
0
Upvotes
0
Know more
153
Total problems solved
140
Easy
13
Moderate
0
Hard
0
Ninja
Jan Jan Feb Feb Mar Mar Apr Apr May May Jun Jun Jul Jul Aug Aug Sep Sep Oct Oct Nov Nov Dec Dec

Current streak:

0 days

Longest streak:

3 days

Less

More

Achievements
1
Ronin
Topics
Arrays
1
Sensei
Guided path
Fundamentals of Html
Discussions
Easy Solution
Interview problems

#include <bits/stdc++.h> 

vector<int> Klargest(vector<int> &a, int k, int n) {

    // Write your code here

    sort(a.begin(),a.end());

    vector<int>ans;

    for(int i=0;i<k;i++){

        ans.push_back(a[n-i-1]);

    }

    sort(ans.begin(),ans.end());

    return ans;

}

 

profile
Adi Boghawala
Published On 01-May-2023
27 views
0 replies
0 upvotes