Java | O(1) time | 1D Array
```\nclass LUPrefix {\n    \n    boolean[] uploaded;\n    int max;\n    int size;\n    public LUPrefix(int n) {\n        uploaded = new boolean[n + 1];\n       
```\nclass LUPrefix {\n    \n    boolean[] uploaded;\n    int max;\n    int size;\n    public LUPrefix(int n) {\n        uploaded = new boolean[n + 1];\n        max = 0;\n        size = n;\n    }\n    \n    public void upload(int video) {\n        uploaded[video] = true;\n\t\t\n\t\t/** \n\t\tIf the longest uploaded prefix is not the previous video then \n\t\tthere must be some other video (smaller than current video) which is not uploaded yet \n\t\t*/\n        if(max != video - 1) return;\n\t\t\n\t\t/** \n\t\tIf the longest uploaded prefix is the previous video then we can conclude that \n\t\tall the videos before it have been uploaded. \n\t\t\n\t\tNow we need to check all videos (greater than current video) that have been uploaded and form a contigous subarray\n\t\t*/\n        while(video <= size && uploaded[video]){\n            video++;\n        }\n        max = video - 1;\n    }\n    \n    public int longest() {\n        return max;\n    }\n}\n
['Array', 'Java']