Search
⌘K

Leetcode 2037. Minimum Number of Moves to Seat Everyone

Given positions of n seats and n students, minimize the total number of moves (sum of absolute position changes) to assign each student to a distinct seat; this reduces to pairing students and seats to minimize the sum of absolute differences (optimal via sorting both arrays and matching corresponding elements).


Question Timeline

See when this question was last asked and where, including any notes left by other candidates.

Comments

Your account is free and you can post anonymously if you choose.