Leetcode 1329 Solution
This article provides solution to leetcode question 1329 (minimum-cost-to-move-chips-to-the-same-position)
Access this page by simply typing in "lcs 1329" in your browser address bar if you have bunnylol configured.
Leetcode Question Link
https://leetcode.com/problems/minimum-cost-to-move-chips-to-the-same-position
Solution
class Solution:
def minCostToMoveChips(self, positions: List[int]) -> int:
odd = 0
even = 0
for pos in positions:
if pos % 2 == 0:
even += 1
else:
odd += 1
return min(odd, even)