Answer: Hitachi Hiring Challenge | Online Assessment Question | Off-Campus (2023)
Answer · Posted Jun 2026
Approach Moving chips between positions of the same parity (even-even or odd-odd) is free. A cost is incurred only when moving a chip between even and odd positions. Count the number of chips at even positions and odd positions. The answer is the smaller of the two counts. Strategy Count chips at even positions. Count chips at odd positions. Return min(evenCount, oddCount). Java Code class Solution { public int minCostToMoveChips(int[] position) { int evenCount = 0; int oddCount = 0; ...
The full answer & interview discussion are available to premium members.
Log in Create a free account