C++ | Set | Easy Understanding
Approach \n- We will insert number in set s.\n- When the longest() function will be called, the set will try to increase the answer by checking the next values.
**Approach** \n- We will insert number in set `s`.\n- When the `longest()` function will be called, the set will try to increase the answer by checking the next values.\n\n**C++ Code**\n\n```cpp\nclass LUPrefix {\n   public:\n    set<int> s;\n    int t = 0;\n    LUPrefix(int n) {\n    }\n\n    void upload(int video) {\n        s.emplace(video);\n    }\n\n    int longest() {\n        while (s.count(t + 1)) {\n            t++;\n        }\n        return t;\n    }\n};\n```
['C']