Skip to content

Commit de20057

Browse files
authored
Merge pull request neetcode-gh#1790 from josuebrunel/feat/1985-Find-the-Kth-Largest-Integer-in-the-Array.go
go: add 1985-Find-the-Kth-Largest-Integer-in-the-Array solution
2 parents bbf0985 + 0e06788 commit de20057

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import "sort"
2+
3+
func kthLargestNumber(nums []string, k int) string {
4+
sort.Slice(nums, func(i, j int) bool {
5+
if len(nums[i]) != len(nums[j]) {
6+
return len(nums[i]) > len(nums[j])
7+
}
8+
for idx := range nums[i] {
9+
if nums[i][idx] != nums[j][idx] {
10+
return nums[i][idx] > nums[j][idx]
11+
}
12+
}
13+
return true
14+
})
15+
return nums[k-1]
16+
}

0 commit comments

Comments
 (0)