1 class Solution: 2 def minCostToMoveChips(self, chips: List[int]) -> int: 3 n = len(chips) 4 odd,even = 0,0 5 for i in range(n): 6 cur = chips[i] 7 if cur % 2 == 0: 8 even += 1 9 else: 10 odd += 1 11 return min(even,odd)
2024-01-03 10:48:10
1 class Solution: 2 def minCostToMoveChips(self, chips: List[int]) -> int: 3 n = len(chips) 4 odd,even = 0,0 5 for i in range(n): 6 cur = chips[i] 7 if cur % 2 == 0: 8 even += 1 9 else: 10 odd += 1 11 return min(even,odd)