Minimum Cost to Move Chips to The Same Position
Easy
Topics
Chips are at positions given by nums. Moving a chip by 2 costs 0; moving it by 1 costs 1. Return the minimum total cost to move all chips to the same position. Even and odd positions split into two groups, so the answer is the size of the smaller group.
Example 1
Input: position = [1,2,3] Output: 1
Example 2
Input: position = [2,2,2,3,3] Output: 2
Constraints
- 1 <= nums.length <= 100
- 1 <= nums[i] <= 10^9
Run ⌘' · Submit ⌘⏎