You are viewing a single comment's thread. Return to all comments →
Simple Swift Solution
func equalizeArray(arr: [Int]) -> Int { var memberAmount = [Int: Int]() let distinct = Array(Set(arr)) for i in 0..<distinct.count { let count = arr.filter { $0 == distinct[i] }.count memberAmount[distinct[i]] = count } return arr.count - (memberAmount.values.max() ?? 0) }
Seems like cookies are disabled on this browser, please enable them to open this website
Equalize the Array
You are viewing a single comment's thread. Return to all comments →
Simple Swift Solution