原题题目
代码实现(首刷自解)
class Solution {
public:int minCostToMoveChips(vector<int>& position) {
int odd = 0,even = 0;for(const auto& num:position){
if(num%2) ++odd;else ++even;}return odd < even ? odd : even;}
};
class Solution {
public:int minCostToMoveChips(vector<int>& position) {
int odd = 0,even = 0;for(const auto& num:position){
if(num%2) ++odd;else ++even;}return odd < even ? odd : even;}
};