-
Notifications
You must be signed in to change notification settings - Fork 0
/
2037.py
43 lines (27 loc) · 842 Bytes
/
2037.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
'''2037. Minimum Number of Moves to Seat Everyone
Created on 2024-06-16 16:47:14
@author: MilkTea_shih
'''
#%% Packages
#%% Variable
#%% Functions
class Solution:
def minMovesToSeat(self, seats: list[int], students: list[int]) -> int:
result: int = 0
seats.sort()
students.sort()
index: int = 0
while index < len(seats):
seat, student = seats[index], students[index]
result += abs(seat - student)
index += 1
return result
class Solution_one_line:
def minMovesToSeat(self, seats: list[int], students: list[int]) -> int:
return sum(abs(seat - student) for seat, student
in zip(*map(sorted, (seats, students)))) # type: ignore
#%% Main Function
#%% Main
if __name__ == '__main__':
pass
#%%