[Python3] One-Pass Solution O(n), Clean & Concise
\nclass LUPrefix:\n\n    def __init__(self, n: int):\n        self.videos = [False] * (n + 1)\n        self.ans = 0\n\n    def upload(self, video: int) -> None:
```\nclass LUPrefix:\n\n    def __init__(self, n: int):\n        self.videos = [False] * (n + 1)\n        self.ans = 0\n\n    def upload(self, video: int) -> None:\n        self.videos[video] = True\n        if video == self.ans + 1:\n            while video < len(self.videos):\n                if not self.videos[video]:\n                    break\n                self.ans += 1\n                video += 1\n\n    def longest(self) -> int:\n        return self.ans\n```
['Python', 'Python3']