Skip to content

Commit 8ad31b8

Browse files
committed
Create index.kt
1 parent a4d8e48 commit 8ad31b8

File tree

1 file changed

+11
-0
lines changed
  • minimum-number-of-moves-to-seat-everyone

1 file changed

+11
-0
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package com.github.masx200.leetcode_test.minimum_number_of_moves_to_seat_everyone
2+
3+
import kotlin.math.abs
4+
5+
class Solution {
6+
fun minMovesToSeat(seats: IntArray, students: IntArray): Int {
7+
seats.sort()
8+
students.sort()
9+
return seats.mapIndexed { i, v -> abs(v - students[i]) }.sum()
10+
}
11+
}

0 commit comments

Comments
 (0)