You are viewing a single comment's thread. Return to all comments →
golang
func sockMerchant(n int32, ar []int32) int32 { bucket := make(map[int32]int32) for _, sockColor := range ar { count, exists := bucket[sockColor] if exists { bucket[sockColor] = count + 1 } else { bucket[sockColor] = 1 } } pairs := int32(0) for _, j := range bucket { pairs += j / 2 } return pairs }
Seems like cookies are disabled on this browser, please enable them to open this website
Sales by Match
You are viewing a single comment's thread. Return to all comments →
golang