Minimum Cost to Move Chips to The Same Position
Solve this the way you would in the interview: out loud, on a timer, with an AI interviewer asking follow-ups while you code. You get a scored report at the end.
Practice this as a mock interviewFree to start, no account neededProblem
There are n chips on a number line; position[i] is where chip i sits (several chips may share a
position). You want all chips on the same position.
In one move you can shift a single chip by 2 in either direction for free, or by 1 in either direction
at a cost of 1.
Return the minimum total cost to gather all chips at one position.
Examples
Constraints
- 1 <= position.length <= 100
- 1 <= position[i] <= 10^9
What the interviewer grades
A correct solution is one of five scores. The report also grades problem understanding (did you clarify inputs and edge cases before coding), problem solving, communication while you work, code quality, and testing. See a sample report, or read up on the pattern in the lessons.