2037. Minimum Number of Moves to Seat Everyone
There are
nseats andnstudents in a room. You are given an arrayseatsof lengthn, whereseats[i]is the position of theithseat. You are also given the arraystudentsof lengthn, wherestudents[j]is the position of thejthstudent.You may perform the following move any number of times:
- Increase or decrease the position of the
ithstudent by1(i.e., moving theithstudent from positionxtox + 1orx - 1)Return the minimum number of moves required to move each student to a seat such that no two students are in the same seat.
Note that there may be multiple seats or students in the same position at the beginning.
1 | class Solution { |