Python & Javascript  // short and simple solution // similar to prob. no. 849
Python\n\nclass ExamRoom:\n\n    def __init__(self, N):\n        self.seated, self.n = [], N - 1\n        \n\n    def seat(self):\n        if not self.seated:\n
* Python\n```\nclass ExamRoom:\n\n    def __init__(self, N):\n        self.seated, self.n = [], N - 1\n        \n\n    def seat(self):\n        if not self.seated:\n            self.seated += 0,\n            return 0\n        mx = ind = 0\n        for i in range(1, len(self.seated)):\n            l, r = self.seated[i - 1], self.seated[i]\n            if (r - l) // 2 > mx:\n                mx = (r - l) // 2\n                ind = l + mx\n        if self.seated[-1] != self.n and self.n - self.seated[-1] > mx:\n            mx, ind = self.n - self.seated[-1], self.n\n        if self.seated[0] >= mx:\n            mx, ind = self.seated[0], 0\n        self.seated.append(ind)\n        self.seated.sort()\n        return ind\n        \n        \n    def leave(self, p):\n        self.seated.remove(p)\n\n```\n* Javascript\n```\nvar ExamRoom = function(N) {\n    this.seats = [], this.n = N - 1;\n};\n\n\nExamRoom.prototype.seat = function() {\n    if (this.seats.length == 0) {\n       this.seats = [0];\n        return 0;\n    }\n    let mx = ind = 0, n = this.seats.length;\n    for (let i = 1; i < n; i++) {\n        l = this.seats[i - 1], r = this.seats[i];\n        d = Math.floor((r - l) / 2);\n        if (d > mx) {\n            mx = d, ind = l + d;\n        }\n    }\n    if (this.seats[n - 1] != this.n && this.n - this.seats[n - 1] > mx) {\n        mx = this.n - this.seats[n - 1], ind = this.n;\n    }\n    if (this.seats[0] >= mx) {\n        mx = this.seats[0], ind = 0;\n    }\n    this.seats.push(ind);\n    this.seats.sort(function (a, b) {return a - b;});\n    return ind;\n};\n\n\nExamRoom.prototype.leave = function(p) {\n    this.seats.splice(this.seats.indexOf(p), 1);\n};\n```
[]