Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit1dcb3b2

Browse files
[CREATE] [CPP] 215. Kth Largest Element in an Array
1 parent8ec5926 commit1dcb3b2

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
classSolution {
2+
public:
3+
intfindKthLargest(vector<int>& nums,int k) {
4+
priority_queue<int, vector<int>, greater<int>>pq(nums.begin(), nums.end());
5+
while (pq.size() > k)pq.pop();
6+
return pq.top();
7+
}
8+
};

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp