Skip to content

Commit 3c7f508

Browse files
committed
Add solution #1985
1 parent 2decb83 commit 3c7f508

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -439,6 +439,7 @@
439439
1920|[Build Array from Permutation](./1920-build-array-from-permutation.js)|Easy|
440440
1929|[Concatenation of Array](./1929-concatenation-of-array.js)|Easy|
441441
1935|[Maximum Number of Words You Can Type](./1935-maximum-number-of-words-you-can-type.js)|Easy|
442+
1985|[Find the Kth Largest Integer in the Array](./1985-find-the-kth-largest-integer-in-the-array.js)|Medium|
442443
1996|[The Number of Weak Characters in the Game](./1996-the-number-of-weak-characters-in-the-game.js)|Medium|
443444
2000|[Reverse Prefix of Word](./2000-reverse-prefix-of-word.js)|Easy|
444445
2011|[Final Value of Variable After Performing Operations](./2011-final-value-of-variable-after-performing-operations.js)|Easy|
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/**
2+
* 1985. Find the Kth Largest Integer in the Array
3+
* https://leetcode.com/problems/find-the-kth-largest-integer-in-the-array/
4+
* Difficulty: Medium
5+
*
6+
* You are given an array of strings nums and an integer k. Each string in nums
7+
* represents an integer without leading zeros.
8+
*
9+
* Return the string that represents the kth largest integer in nums.
10+
*
11+
* Note: Duplicate numbers should be counted distinctly. For example, if nums is
12+
* ["1","2","2"], "2" is the first largest integer, "2" is the second-largest
13+
* integer, and "1" is the third-largest integer.
14+
*/
15+
16+
/**
17+
* @param {string[]} nums
18+
* @param {number} k
19+
* @return {string}
20+
*/
21+
var kthLargestNumber = function(nums, k) {
22+
return String(nums.map(BigInt).sort((a, b) => b - a >= 0 ? 1 : -1)[k - 1]);
23+
};

0 commit comments

Comments
 (0)