You are viewing a single comment's thread. Return to all comments →
My solution on golang :) I was surprised because this solution performed better than the first one I made using a MAP.
func migratoryBirds(arr []int32) int32 { var frequentType int32 birdIDs := [5]int{} for _, bird := range arr { switch bird { case 1: birdIDs[0]++ case 2: birdIDs[1]++ case 3: birdIDs[2]++ case 4: birdIDs[3]++ case 5: birdIDs[4]++ } } aux := birdIDs[0] for i := 1; i < len(birdIDs); i++ { if aux < birdIDs[i] { aux = birdIDs[i] frequentType = int32(i) + 1 } } return frequentType }
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 →
My solution on golang :) I was surprised because this solution performed better than the first one I made using a MAP.