C++ Solution Using Set and Vector
\n\n# Complexity\n- Time complexity:O(N)\n Add your time complexity here, e.g. O(n) \n\n- Space complexity:O(N)\n Add your space complexity here, e.g. O(n) \n\n
\n\n# Complexity\n- Time complexity:O(N)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:O(N)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code using Set\n```\nclass Solution {\npublic:\n    vector<int> circularGameLosers(int n, int k) {\n        vector<int> ans;\n        unordered_set<int> s;\n        int turn=1;\n        int curr=1;\n        while(1){\n            s.insert(curr);\n            curr+=turn*k;\n            if(curr>n) curr%=n;\n            if(curr==0) curr=n;\n            turn++;\n            if(s.find(curr)!=s.end())\n                break;\n            \n        }\n        for(int i=1;i<=n;i++){\n            if(s.find(i)==s.end())\n                ans.push_back(i);\n            \n        }\n        return ans;\n        \n    }\n};\n```\n\n\n# Code using Vector\n```\nclass Solution {\npublic:\n    vector<int> circularGameLosers(int n, int k) {\n        vector<int> v(n+1,0);\n        int curr=1,turn=1;\n         while(v[curr]==0){\n             v[curr]++;\n             curr=(curr+turn*k)%n;\n             if(curr==0) curr=n;\n             turn++;\n        }\n        vector<int> ans;\n        for(int i=1;i<=n;i++){\n            if(v[i]==0)\n              ans.push_back(i);\n        }\n        return ans;\n    }\n};\n```
['C++']