Easy to understand using array.
\nclass LUPrefix:\n\n    def __init__(self, n: int):\n        self.i = 0\n        self.l = [0]*(n+1)\n        self.n = n\n\n    def upload(self, video: int) -> 
```\nclass LUPrefix:\n\n    def __init__(self, n: int):\n        self.i = 0\n        self.l = [0]*(n+1)\n        self.n = n\n\n    def upload(self, video: int) -> None:\n        if video==1:\n            self.i = 1\n        self.l[video]=1\n        while(self.i<self.n):\n            if self.l[self.i+1]==1:\n                self.i+=1\n            else:\n                break\n    def longest(self) -> int:\n        return self.i\n```
['Python', 'Python3']