Two very efficient Solutions | Python
Sorted List solution:\n\nfrom sortedcontainers import SortedList\n\nclass LUPrefix:\n    def __init__(self, n: int):\n        self.notUploaded = SortedList(i fo
**Sorted List** solution:\n```\nfrom sortedcontainers import SortedList\n\nclass LUPrefix:\n    def __init__(self, n: int):\n        self.notUploaded = SortedList(i for i in range(n + 1))\n    # Time: O(n)\n    # Space: O(n)\n\n    def upload(self, video: int) -> None:\n        self.notUploaded.remove(video - 1)\n    # Time: O(log(n))\n    # Space: O(1)\n\n    def longest(self) -> int:\n        return self.notUploaded[0]\n    # Time: O(1)\n    # Space: O(1)\n```\n\\\nAlternative solution:\n```\nclass LUPrefix:\n    def __init__(self, n: int):\n        self.ds = [False] * n\n        self.mx = 0\n    # Time: O(n)\n    # Space: O(n)\n\n    def upload(self, video: int) -> None:\n        self.ds[video - 1] = True\n        while self.mx < len(self.ds) and self.ds[self.mx]:\n            self.mx += 1\n    # Time: O(m) where m is video\n    # Space: O(1)\n\n    def longest(self) -> int:\n        return self.mx\n    # Time: O(1)\n    # Space: O(1)\n```
['Python']