Skip to content

Commit 0729718

Browse files
committed
Add solution #215
1 parent 9a84e27 commit 0729718

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@
9393
206|[Reverse Linked List](./0206-reverse-linked-list.js)|Easy|
9494
213|[House Robber II](./0213-house-robber-ii.js)|Medium|
9595
214|[Shortest Palindrome](./0214-shortest-palindrome.js)|Hard|
96+
215|[Kth Largest Element in an Array](./0215-kth-largest-element-in-an-array.js)|Medium|
9697
217|[Contains Duplicate](./0217-contains-duplicate.js)|Easy|
9798
219|[Contains Duplicate II](./0219-contains-duplicate-ii.js)|Easy|
9899
225|[Implement Stack using Queues](./0225-implement-stack-using-queues.js)|Easy|
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/**
2+
* 215. Kth Largest Element in an Array
3+
* https://leetcode.com/problems/kth-largest-element-in-an-array/
4+
* Difficulty: Medium
5+
*
6+
* Given an integer array nums and an integer k, return the kth largest element in the array.
7+
*
8+
* Note that it is the kth largest element in the sorted order, not the kth distinct element.
9+
*/
10+
11+
/**
12+
* @param {number[]} nums
13+
* @param {number} k
14+
* @return {number}
15+
*/
16+
var findKthLargest = function(nums, k) {
17+
return nums.sort((a, b) => a - b)[nums.length - k];
18+
};

0 commit comments

Comments
 (0)