Skip to content

Commit 8c3c9d8

Browse files
author
hasibulislam999
committed
Find the Kth Largest Integer in the Array problem solved
1 parent 699c829 commit 8c3c9d8

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/**
2+
* Title: Find the Kth Largest Integer in the Array
3+
* Description: You are given an array of strings nums and an integer k. Each string in nums represents an integer without leading zeros.
4+
* Author: Hasibul Islam
5+
* Date: 03/04/2023
6+
*/
7+
8+
/**
9+
* @param {string[]} nums
10+
* @param {number} k
11+
* @return {string}
12+
*/
13+
var kthLargestNumber = function (nums, k) {
14+
let arr = [...nums].map((x) => BigInt(x)).sort((a, b) => (a >= b ? -1 : 1));
15+
return arr[k - 1].toString();
16+
};
17+
18+
console.log(kthLargestNumber(["3", "6", "7", "10"], 4));

0 commit comments

Comments
 (0)