Java | Easy Understanding
Hi Family,\n\nI did this question using Array\n\n\nclass LUPrefix {\n    \n    // declare the array\n    int ar[];\n    int max_cnt = 1;\n\n    public LUPrefix(
Hi Family,\n\nI did this question using Array\n\n```\nclass LUPrefix {\n    \n    // declare the array\n    int ar[];\n    int max_cnt = 1;\n\n    public LUPrefix(int n) {\n        //initialize the array\n        ar = new int[n+2];\n    }\n    \n    public void upload(int video) {\n        ar[video] = 1;\n        // check everytime from the max index \n        while (ar[max_cnt] == 1) {\n            max_cnt++;\n        }\n    }\n    \n    public int longest() {\n        \n        return max_cnt-1;\n    }\n}\n```\n\n**If you liked the code Please Please Please Upvote it**\n\n\n**Thanks!!!**\n\n
['Array', 'Java']