luoheng
10/11/2019 - 7:31 AM

minCostToMoveChips

func minCostToMoveChips(chips []int) int {
    odd, even := 0, 0
    for _, c := range chips {
        if c % 2 == 0 {
            odd++
        } else {
            even++
        }
    }
    if odd > even {
        return even
    }
    return odd
}