problem 2037

This commit is contained in:
Yudhvir Singh
2024-06-13 11:15:33 -07:00
parent 64b762172d
commit ed9774da22
2 changed files with 74 additions and 0 deletions

View File

@@ -0,0 +1,17 @@
from typing import List
class Solution:
def minMovesToSeat(self, seats: List[int], students: List[int]) -> int:
if len(seats) == 1 or len(students) == 0:
return 0
# sort seats
seats.sort()
students.sort()
# now get the diff as number of moves
num_moves = 0
for i in range(len(seats)):
num_moves += abs(seats[i] - students[i])
return num_moves