Java Average Time complexity O(1)
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass LUPrefix {\n    int[] ans;\n    int uploadedUpto;\n    public LUPrefix(int n) {\n        ans = new int[n];\n    }\n    \n    public void upload(int video) {\n        ans[video-1] = 1;\n    }\n    \n    public int longest() {\n        for(int i=uploadedUpto;i<ans.length;i++) {\n            if(ans[i] == 1) {\n                uploadedUpto++;\n            } else {\n                break;\n            }\n        }\n        return uploadedUpto;\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```
['Java']