Skip to content

Commit 5632d7d

Browse files
authored
Create Minimum Cost to Move Chips to The Same Position.java
1 parent ee8a4c1 commit 5632d7d

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
class Solution {
2+
public int minCostToMoveChips(int[] position) {
3+
int evenCount = 0;
4+
int oddCount = 0;
5+
for (int p : position) {
6+
if (p % 2 == 0) {
7+
evenCount++;
8+
} else {
9+
oddCount++;
10+
}
11+
}
12+
return Math.min(evenCount, oddCount);
13+
}
14+
}

0 commit comments

Comments
 (0)