2037. Minimum Number of Moves to Seat Everyone
There are
n
seats andn
students in a room. You are given an arrayseats
of lengthn
, whereseats[i]
is the position of theith
seat. You are also given the arraystudents
of lengthn
, wherestudents[j]
is the position of thejth
student.You may perform the following move any number of times:
- Increase or decrease the position of the
ith
student by1
(i.e., moving theith
student from positionx
tox + 1
orx - 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 { |