Python Bisect Insort
Use a sorted list self.occupied to keep track of everyone\'s position. Everytime a new person comes in, find the best location between left and right and seat t
Use a sorted list `self.occupied` to keep track of everyone\'s position. Everytime a new person comes in, find the best location between `left` and `right` and seat the person in `(left + right) // 2` using `bisect.insort()`. Don\'t forget the consider the positions before the first person `self.occupied[0]` and after the last person `self.occupied[-1]`.\n```\nclass ExamRoom:\n    def __init__(self, N: int):\n        self.occupied = []\n        self.N = N\n\n    def seat(self) -> int:\n        if not self.occupied: \n            self.occupied.append(0)\n            return 0\n        left, right = -self.occupied[0], self.occupied[0]\n        maximum = (right - left) // 2\n        for start, end in zip(self.occupied, self.occupied[1:] + [2 * self.N - 2 - self.occupied[-1]]):\n            if (end - start) // 2 > maximum:\n                left, right = start, end\n                maximum = (right - left) // 2\n        bisect.insort(self.occupied, left + maximum)\n        return left + maximum\n            \n    def leave(self, p: int) -> None:\n        self.occupied.remove(p)\n```
['Python']