Skip to content

Commit ec0169b

Browse files
authored
Create play-with-chips.cpp
1 parent 5830946 commit ec0169b

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

C++/play-with-chips.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// Time: O(n)
2+
// Space: O(1)
3+
4+
class Solution {
5+
public:
6+
int minCostToMoveChips(vector<int>& chips) {
7+
vector<int> count(2);
8+
for (const auto& p : chips) {
9+
++count[p % 2];
10+
}
11+
return min(count[0], count[1]);
12+
}
13+
};

0 commit comments

Comments
 (0)