2037 - Minimum Number of Moves to Seat Everyone - Easy

Table of contents
  1. Problem

Problem

Long story short:

  • You are given two arrays of integers seats and students.
  • Each has $n$ elements.
  • We want to match the elements of students to the elements of seats (order doesn’t matter).
  • On each move we can increment or decrement one element of students by 1.
  • Return the minimum number of moves to match the elements.

seats may contain duplicates.