Python3 solution using list O(1) time, O(n) memory
IntuitionApproachComplexity

Time complexity:
O(1) for each of operations, O(n) if we include array initialization in constructor.


Space complexity:
O(n)

Cod
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->

# Approach
<!-- Describe your approach to solving the problem. -->

# Complexity
- Time complexity:
O(1) for each of operations, O(n) if we include array initialization in constructor. 

- Space complexity:
O(n)

# Code
```python3 []
class LUPrefix:

    def __init__(self, n: int):
        self.array = [0]*n
        self.n = n

    def upload(self, video: int) -> None:
        idx = video - 1
        
        max_len_left = 0
        if idx > 0:
            max_len_left = self.array[idx - 1]
        
        max_len_right = 0
        if idx < self.n - 1:
            max_len_right = self.array[idx + 1]
            
        new_size = max_len_left + max_len_right + 1

        self.array[idx] = new_size
        if idx - max_len_left >= 0:
            self.array[idx - max_len_left] = new_size

        if idx + max_len_right < self.n:
            self.array[idx + max_len_right] = new_size

    def longest(self) -> int:
        return self.array[0]
        


# Your LUPrefix object will be instantiated and called as such:
# obj = LUPrefix(n)
# obj.upload(video)
# param_2 = obj.longest()
```
['Python3']