Clean python solution
python\nclass ExamRoom:\n\n    def __init__(self, N: int):\n        self.n = N\n        self.seats = []\n\n    def seat(self) -> int:\n        n = self.n\n     
```python\nclass ExamRoom:\n\n    def __init__(self, N: int):\n        self.n = N\n        self.seats = []\n\n    def seat(self) -> int:\n        n = self.n\n        last_seat = -1\n        dist = 0\n        seat = -1\n        idx = -1\n        \n        for i in range(len(self.seats)):\n            if last_seat == -1:\n                if self.seats[i] > dist:\n                    dist = self.seats[i]\n                    seat = 0\n                    idx = 0\n            else:\n                if (self.seats[i]-last_seat)//2 > dist:\n                    dist = (self.seats[i]-last_seat)//2\n                    seat = (self.seats[i]+last_seat)//2\n                    idx = i\n            last_seat = self.seats[i]\n        \n        if last_seat == -1:\n            seat = 0\n            idx = 0\n        else:\n            if n-1-last_seat > dist:\n                dist = n-1-last_seat\n                seat = n-1\n                idx = len(self.seats)\n        \n        self.seats.insert(idx, seat)\n        return seat\n        \n    def leave(self, p: int) -> None:\n        self.seats.remove(p) # can use binary search and reduce to log(n)\n\n# Your ExamRoom object will be instantiated and called as such:\n# obj = ExamRoom(N)\n# param_1 = obj.seat()\n# obj.leave(p)\n```
[]