Extremely Easy Solution | Vector instead of Set | Linear Solution
We can just use a vector and resize it to n to initialize it. We can maintain a global variable named last wihch will tell us the longest video which we can see
We can just use a vector and resize it to n to initialize it. We can maintain a global variable named last wihch will tell us the longest video which we can see. Total Time Complexity will be O(N) but Amortized Time Complexity will be O(1). If it helped u, don\'t forget to upvote.\uD83D\uDE03\n```\nclass LUPrefix {\n    vector<int>v;\n    int last = 0;\npublic:\n    LUPrefix(int n) {\n        v.resize(n);\n    }\n    \n    void upload(int video) { \n        v[video - 1] = 1;\n    }\n    \n    int longest() {\n         while(last < v.size() && v[last] == 1){\n            last++;\n        }\n        return last;\n    }\n};\n```
[]