Union Find | with concise comment
\nclass LUPrefix {\npublic:\n    const int OFFLINE = -1;\n    const int MAIN_SERVER = 1;\n    vector<int> root;\n    vector<int> rank;\n    LUPrefix(int n) {\n 
```\nclass LUPrefix {\npublic:\n    const int OFFLINE = -1;\n    const int MAIN_SERVER = 1;\n    vector<int> root;\n    vector<int> rank;\n    LUPrefix(int n) {\n        root = vector<int>(n+1, OFFLINE);\n        rank = vector<int>(n+1, 1);\n    }\n\n    int find (const int i) {\n        if (i == -1 || root[i] == i)\n            return i;\n        return root[i] = find(root[i]);\n    }\n    \n    void merge(const int i, const int j) {\n        int u = find(i), v = find(j);\n        \n        if (v > u) //adopt the fareset server as our server root\n            swap(u, v);\n        \n        root[v] = root[u];\n        rank[u] += rank[v];\n    }\n\n    void upload(const int video) {\n        root[video] = video; //active the server of current video\n        \n        if (video+1 < root.size() && find(root[video+1]) != OFFLINE) // nearby left server has been actived\n                merge(video, video+1);\n\n        if (video-1 >= 0 && find(root[video-1]) != OFFLINE) // nearby right server has been actived\n                merge(video, video-1);\n\n    }\n    \n    int longest() {\n        return find(root[MAIN_SERVER]) == OFFLINE ? 0 : find(root[MAIN_SERVER]); //return which the farest server that ROOT server can reach\n    }\n};\n```
['Union Find', 'C']