There are n available seats and n students in a room. seats[i] is the position of the ith seat and students[j] is the position of the jth student. In one move you can shift one student one position left or right. Return the minimum number of moves needed so that every student sits in a seat and no two students share a seat. Several seats or students may start at the same position.
There are n available seats and n students in a room. seats[i] is the position of the ith seat and students[j] is the position of the jth student. In one move you can shift one student one position left or right. Return the minimum number of moves needed so that every student sits in a seat and no two students share a seat. Several seats or students may start at the same position.
Example 1:
Input: {"seats":[3,1,5],"students":[2,7,4]}
Output: 4
Constraints:
n=seats.length=students.length
1≤n≤100
1≤seats[i],students[j]≤100
Test Cases
Input (Stdin)
Expected Output (Stdout)
Execution Result
Run code to see results.
Input
arr ={"seats":[3,1,5],"students":[2,7,4]}
3 seats (squares) and 3 students (dots) on one row. Each step moves a student one position.