Java Solution | Small Code
\nclass LUPrefix {\n    \n    Set<Integer> set;\n    int maxVideoPrefix = 0;\n    \n    public LUPrefix(int n) {\n        set = new HashSet<>();\n    }\n    \n 
```\nclass LUPrefix {\n    \n    Set<Integer> set;\n    int maxVideoPrefix = 0;\n    \n    public LUPrefix(int n) {\n        set = new HashSet<>();\n    }\n    \n    public void upload(int video) {\n        set.add(video);\n        while(set.contains(maxVideoPrefix+1)) {\n            maxVideoPrefix++;\n        }\n    }\n    \n    public int longest() {\n        return maxVideoPrefix;\n    }\n}\n\n```
['Java']