Tap here to switch tabs
Problem
Submissions

Problem: Minimum Number of Moves to Seat Everyone

Try to solve the Minimum Number of Moves to Seat Everyone problem.

Statement

There are nn seats and nn students in a room. You are given an integer array seats of length nn, where seats[i] represents the position of the ithi^{ {th}} seat. You are also given an integer array students of length nn, where students[j] represents the position of the jthj^{ {th}} student.

In one move, you can increase or decrease the position of any student by 11.

Return the minimum number of moves required to move each student to a seat such that each student occupies a unique seat.

Note: Multiple seats or students can share the same initial position.

Constraints:

  • n == seats.length == students.length

  • 1≤1 \leq n ≤100\leq 100

  • 1≤1 \leq seats[i], students[j] ≤100\leq 100

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Minimum Number of Moves to Seat Everyone

Try to solve the Minimum Number of Moves to Seat Everyone problem.

Statement

There are nn seats and nn students in a room. You are given an integer array seats of length nn, where seats[i] represents the position of the ithi^{ {th}} seat. You are also given an integer array students of length nn, where students[j] represents the position of the jthj^{ {th}} student.

In one move, you can increase or decrease the position of any student by 11.

Return the minimum number of moves required to move each student to a seat such that each student occupies a unique seat.

Note: Multiple seats or students can share the same initial position.

Constraints:

  • n == seats.length == students.length

  • 1≤1 \leq n ≤100\leq 100

  • 1≤1 \leq seats[i], students[j] ≤100\leq 100