Easy and optimized python3 solution
class LUPrefix:\n\n    def init(self, n: int):\n        \n        self.v = [0]*(n+1)\n        self.cur = 1\n        \n\n    def upload(self, video: int) -> None
class LUPrefix:\n\n    def __init__(self, n: int):\n        \n        self.v = [0]*(n+1)\n        self.cur = 1\n        \n\n    def upload(self, video: int) -> None:\n        self.v[video] = 1\n        if video == self.cur:\n            self.cur+=1\n        \n        while self.cur<len(self.v) and self.v[self.cur]!=0:\n            self.cur+=1\n\n\n    def longest(self) -> int:\n        return self.cur-1
['Python3']