Practice Minimum Number of Moves to Seat Everyone
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Problem Statement
There are equally many seats and students, with positions given by seats and students. A move changes one student’s position by 1 in either direction. Assign every student to a different seat and return the minimum total moves needed. Distinct seats may share a position, and multiple students may initially share a position.
Source: Minimum Number of Moves to Seat Everyone on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
seats = [3,1,5], students = [2,7,4]
4
# Example 2
seats = [4,1,5,9], students = [1,3,2,6]
7
# Example 3
seats = [2,2,6,6], students = [1,3,2,6]
4
Constraints
Related LeetCode Problems
Practice more problems similar to Minimum Number of Moves to Seat Everyone.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.