🤯 [Python] Made Easy | Pointer based approach | Explained
We maintain a pointer to return the longest prefix size. At start the pointer stays at 0, Since we know there cant be a 0 video, so the pointer stays at 0 until
We maintain a pointer to return the longest prefix size. At start the pointer stays at 0, Since we know there cant be a 0 video, so the pointer stays at 0 until the 1st video is uploaded. As soon as the 1st video gets uploaded, we increase the pointer till the end of the array or till it finds another 0.\n\n**Upvote if you understood the logic :)**\n\n```\nclass LUPrefix:\n\n    def __init__(self, n: int):\n        self.arr = [0] * n\n        self.point = 0\n\n    def upload(self, video: int) -> None:\n        self.arr[video - 1] = video\n        \n        while self.point < len(self.arr) and self.arr[self.point] > 0:\n            self.point += 1\n        \n\n    def longest(self) -> int:\n        return self.point\n```
['Python']