🧽 Java Clean & Simple | Union Find
\nclass LUPrefix {\n    int[] map;\n\n    public LUPrefix(int n) {\n        map = new int[n + 1];\n    }\n\n    public void upload(int video) {\n        map[vid
```\nclass LUPrefix {\n    int[] map;\n\n    public LUPrefix(int n) {\n        map = new int[n + 1];\n    }\n\n    public void upload(int video) {\n        map[video - 1] = find(video);\n    }\n\n    public int longest() {\n        return find(0);\n    }\n\n    int find(int index) {\n        if (map[index] == 0)\n            return index;\n        map[index] = find(map[index]);\n        return map[index];\n    }\n}\n```
['Java']