Python PriorityQueue solution
Same idea with https://leetcode.com/problems/exam-room/discuss/148595/Java-PriorityQueue-with-customized-object.-seat:-O(logn)-leave-O(n)-with-explanation. \n\n
Same idea with https://leetcode.com/problems/exam-room/discuss/148595/Java-PriorityQueue-with-customized-object.-seat:-O(logn)-leave-O(n)-with-explanation. \n\n```\nfrom heapq import heappush, heappop, heapify\nclass Interval:\n    def __init__(self, l, r, N):\n        self.l = l\n        self.r = r\n        if l == -1:\n            self.dist = r\n        elif r == N:\n            self.dist = N - 1 - l\n        else:\n            self.dist = abs(l -r) // 2\n    \n    def __lt__(self, other): \n        if self.dist == other.dist:\n            return self.l < other.l\n        else:\n            return self.dist >= other.dist\n\nclass ExamRoom:\n    def __init__(self, N):\n        self.N = N\n        self.heap = []\n        heappush(self.heap, Interval(-1, N, N))\n\n    def seat(self):\n        """\n        :rtype: int\n        """\n        seat = 0\n        interval = heappop(self.heap)\n        if interval.l == -1: seat = 0\n        elif interval.r == self.N: seat = self.N - 1\n        else: seat = (interval.l + interval.r) // 2\n    \n        heappush(self.heap, Interval(interval.l, seat, self.N))\n        heappush(self.heap, Interval(seat, interval.r, self.N))  \n\n        return seat\n        \n    def leave(self, p):\n        head, tail = None, None\n        for interval in self.heap:\n            if interval.l == p:\n                head = interval\n            elif interval.r == p:\n                tail = interval\n            if head != None and tail != None:\n                break\n        \n        self.heap.remove(head)\n        self.heap.remove(tail)\n        \n        self.heap.append(Interval(tail.l , head.r, self.N))\n        heapify(self.heap)\n```
[]