Python 3 ||  iteration   ||  T/S: 97% / 59%
\nclass LUPrefix:\n\n    def __init__(self, n: int):\n        self.stream = [False]*n\n        self.maxLength = n\n        self.prefLength = 0\n        \n    de
```\nclass LUPrefix:\n\n    def __init__(self, n: int):\n        self.stream = [False]*n\n        self.maxLength = n\n        self.prefLength = 0\n        \n    def upload(self, video: int) -> None:\n        self.stream[video-1] = True\n\n    def longest(self) -> int:\n        for i in range(self.prefLength,self.maxLength):\n\n            if self.stream[i]:\n                self.prefLength = i+1\n\n            else: break\n\n        return self.prefLength\n```\n\n[https://leetcode.com/problems/longest-uploaded-prefix/submissions/1289137170/](https://leetcode.com/problems/longest-uploaded-prefix/submissions/1289137170/)\n\nI could be wrong, but I think that time complexity is *O*(*N*) and space complexity is *O*(*N*).
['Python', 'Python3']