C++ solution with array
Please, upvote if you like it. Thanks :-)Complexity

Time complexity:
O(1)


Space complexity:
O(n)

Code
Please, upvote if you like it. Thanks :-)

# Complexity
- Time complexity:
O(1)

- Space complexity:
O(n)

# Code
```cpp []
class LUPrefix {
public:
    LUPrefix(int n) {
        videos.resize(n + 1);
    }
    
    void upload(int video) {
        videos[video] = 1;
        while (maxUploaded + 1 < videos.size() && videos[maxUploaded + 1] == 1)
            maxUploaded++;
    }
    
    int longest() {
        return maxUploaded;
    }
private:
    int maxUploaded = 0;
    vector<int> videos;
};
```
['Array', 'Design', 'C++']