123456789101112131415161718 |
- package kata
- func HighestRank(nums []int) int {
- counts := make(map[int]int)
- for _, num := range nums {
- counts[num]++
- }
- maxNum, maxCount := -1, 0
- for num, count := range counts {
- if count > maxCount || (count == maxCount && num > maxNum) {
- maxCount = count
- maxNum = num
- }
- }
- return maxNum
- }
|