Leetcode # 2037. Minimum Number of Moves to Seat Everyone
Problem
https://leetcode.com/problems/minimum-number-of-moves-to-seat-everyone
Solution
Time Complexity: O(len(seats) * log(len(seats)))
Space Complexity: O(len(seats))
(The input and output generally do not count towards the space complexity.)
class Solution: def minMovesToSeat(self, seats: List[int], students: List[int]) -> int: seats.sort() students.sort() return sum([abs(seats[i] - students[i]) for i in range(len(seats))])
Last Updated on 2024/12/19 by A1go