Skip to content

Commit

Permalink
Merge pull request neetcode-gh#1790 from josuebrunel/feat/1985-Find-t…
Browse files Browse the repository at this point in the history
…he-Kth-Largest-Integer-in-the-Array.go

go: add 1985-Find-the-Kth-Largest-Integer-in-the-Array solution
  • Loading branch information
Ahmad-A0 authored Jan 1, 2023
2 parents bbf0985 + 0e06788 commit de20057
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions go/1985-find-the-kth-largest-integer-in-the-array.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import "sort"

func kthLargestNumber(nums []string, k int) string {
sort.Slice(nums, func(i, j int) bool {
if len(nums[i]) != len(nums[j]) {
return len(nums[i]) > len(nums[j])
}
for idx := range nums[i] {
if nums[i][idx] != nums[j][idx] {
return nums[i][idx] > nums[j][idx]
}
}
return true
})
return nums[k-1]
}

0 comments on commit de20057

Please sign in to comment.