C++ || Array
Approch :-\n1.] Here I am going to use a three number which is -1,0,1 which is as follows ( -1 -> not uploded, 0 -> uploaded but not created prefix , 1 -> uploa
**Approch** :-\n1.] Here I am going to use a three number which is -1,0,1 which is as follows ( -1 -> not uploded, 0 -> uploaded but not created prefix , 1 -> uploaded and created bond with prefix ).\n2.]  In upload function what i am going to do is if **curr-1th** is connectd with prefix so we can expand prefix from **curr to elm till elm have 0 means already uploaded**.\n3.] Example :- (-1,-1,-1,-1) i.e. no video is uploaded => upload 3rd => (-1,-1,0,-1) => upload 2nd => (-1,0,0,-1) => upload 1 => (1,1,1,-1)\n\n**c++ code**\n```\nint len;\n    int dp[1000002];\n    int longestpre=0;\n        \n    LUPrefix(int n) {\n        len=n;\n        memset(dp,-1,sizeof(dp));\n        dp[0]=1;\n    }\n    \n    void upload(int idx) {\n        dp[idx]=0;\n      \n        if(dp[idx-1]==1){\n            while(idx<=len && dp[idx]==0){\n                longestpre=max(longestpre,idx);\n                dp[idx]=1;\n                idx++;\n            }\n        }\n    }\n    \n    int longest() {\n       return longestpre;\n    }\n\t//code by sachin\n```\n**upvote is solution was helpful**
['Array', 'C', 'C++']