You are viewing a single comment's thread. Return to all comments →
Golang
func migratoryBirds(arr []int32) int32 { var m map[int32]int32 = make(map[int32]int32) for i := range arr { el := arr[i] _, ok := m[el] if !ok { m[el] = 0 } else { continue } for j := range arr { if el == arr[j] { m[el] += 1 } } } var mostFrequentlyId int32 var current int32 for k, o := range m { if o > current { mostFrequentlyId = k current = o } if o == current && k < mostFrequentlyId { mostFrequentlyId = k } } return mostFrequentlyId }
Seems like cookies are disabled on this browser, please enable them to open this website
Migratory Birds
You are viewing a single comment's thread. Return to all comments →
Golang