faster than 95%, CPP, O(n) worst case
1.\tvector<bool> done:\n        \u2022\tThis vector is used to keep track of which videos have been uploaded. The index of the vector corresponds to the video I
1.\t`vector<bool> done`:\n        \u2022\tThis vector is used to keep track of which videos have been uploaded. The index of the vector corresponds to the video ID, and the value at that index indicates whether the video has been uploaded (`true`) or not (`false`).\n\t2.\t`int longestTillNow`:\n\t\u2022\tThis variable keeps track of the longest continuous sequence of uploaded videos starting from video 1. For example, if videos 1, 2, and 3 are uploaded, `longestTillNow` would be 3.\n\t3.\t`int total`:\n\t\u2022\tThis variable stores the total number of videos plus one (to account for indexing from 1). It is initialized to `n + 1`, where `n` is the total number of videos.\n\n    Constructor: `LUPrefix(int n)`\n        \u2022\tThe constructor initializes the `done` vector with a size of `n + 1`, setting all values to `false` (0). It also initializes `longestTillNow` to 0 and sets `total` to `n + 1`.\n    Method: `upload(int video)`\n        \u2022\tThis method is called when a video is uploaded:\n        \u2022\tIt marks the corresponding index in the `done` vector as `true`, indicating that the video has been uploaded.\n        \u2022\tIf the uploaded video ID matches `longestTillNow + 1`, it increments `longestTillNow`. This means if the next expected video (in sequential order) has been uploaded, it extends the longest sequence.\n    Method: `longest()`\n        \u2022\tThis method returns the length of the longest continuous sequence of uploaded videos:\n        \u2022\tIt uses a while loop to check if the next video in sequence (`longestTillNow + 1`) has been uploaded. If it has, it increments `longestTillNow`.\n        \u2022\tThe loop continues until it finds a gap (i.e., a video that hasn\u2019t been uploaded).\n        \u2022\tFinally, it returns the current value of `longestTillNow`.\n\n# Code\n```cpp []\nclass LUPrefix {\npublic:\n    vector<bool> done;\n    int longestTillNow;\n    int total;\n    LUPrefix(int n) {\n        done = vector<bool>(n+1, 0);\n        longestTillNow = 0;\n        total = n+1;\n    }\n    \n    void upload(int video) {\n        done[video]=true; \n        if(video==longestTillNow+1){\n            longestTillNow++;\n        }\n    }\n    \n    int longest() {\n        while(longestTillNow+1<=total && done[longestTillNow+1]) longestTillNow++;\n        return longestTillNow;\n    }\n};\n\n/**\n * Your LUPrefix object will be instantiated and called as such:\n * LUPrefix* obj = new LUPrefix(n);\n * obj->upload(video);\n * int param_2 = obj->longest();\n */\n```
['C++']