C++ | Using Vector | Time Complexity - O(N) | Space Complexity - O(N)
\nclass LUPrefix {\nprivate:\n    int i;\n    int n;\n    vector<int> nums;\npublic:\n    LUPrefix(int N) {\n        i = 0;\n        n = N+2;\n        nums.resi
```\nclass LUPrefix {\nprivate:\n    int i;\n    int n;\n    vector<int> nums;\npublic:\n    LUPrefix(int N) {\n        i = 0;\n        n = N+2;\n        nums.resize(n, -1);\n    }\n    \n    void upload(int video) {\n        nums[video] = 1;\n        while(i<n && (nums[i+1]!=-1)){\n            i++;\n        } \n        return;\n    }\n    \n    int longest() {\n        return i;\n    }\n};\n\n```
['C']