JavaScript solution, 132ms
We are given 2 arrays of the same length, students and seats, and are asked to return the minimum number of moves required to move each student to a seat such t
We are given 2 arrays of the same length, `students` and `seats`, and are asked to *return the minimum number of moves required to move each student to a seat such that no two students are in the same seat*. \n\nThe first thing we must do is sort both arrays so that when we compare them they will return the optimal difference. Do NOT use `seats.sort()` as this will return an incorrect sort (it will sort by the first numeral in a number ex: 1, 10, 2, 3, 434, 5...) and lead to a wrong answer submission.\n- `seats.sort((a, b) => { return a - b})`\n- `students.sort((a, b) => { return a - b})`\n\nNow that the arrays are sorted we want to compare them and return the difference, we can do this by using the reduce method on either of the arrays. Inside the reduce method we set `a` as the accumulator, `b` as the current value, `i` as the iteration, and 0 as the initial value. \n- `seats.reduce((a, b, i) => , 0)`\n\nAs we iterate through the method we want to accumulate the absolute value of the difference between the current iteration in the `seats` and `students` arrays.\n- `a += Math.abs(seats[i] - students[i])`\n\nReturn the method as the final accumulation value will represent out answer.\n- `return seats.reduce((a, b, i) => a += Math.abs(seats[i] - students[i]), 0)`\n\n**Solution 1: 154ms**\n\n```\nvar minMovesToSeat = function(seats, students) {\n    seats.sort((a, b) => { return a - b})\n    students.sort((a, b) => { return a - b})\n    return seats.reduce((a, b, i) => a += Math.abs(seats[i] - students[i]), 0)\n};\n```\n\n---\n\n**Solution 2: 132ms**\n\nThis solution is slightly faster and requires less code. The only difference is that we replace `seats` in the reduce method with `seats.sort((a, b) => { return a - b})` so we can streamline the sorted array into the return statement.\n\n```\nvar minMovesToSeat = function(seats, students) {\n    students.sort((a, b) => { return a - b})\n    return seats.sort((a, b) => { return a - b}).reduce((a, b, i) => a += Math.abs(seats[i] - students[i]), 0)\n};\n```
['JavaScript']