✅ [C++] Using sets
\n\n# Code\n\nclass Solution {\npublic:\n    int maxCount(vector<int>& banned, int n, int maxSum) {\n        set<int> s, s1;\n        for(auto i: banned){\n    
\n\n# Code\n```\nclass Solution {\npublic:\n    int maxCount(vector<int>& banned, int n, int maxSum) {\n        set<int> s, s1;\n        for(auto i: banned){\n            s.insert(i);\n        }\n        \n        for(int i=1; i<=n; i++){\n            if(s.find(i)==s.end())\n                s1.insert(i);\n        }\n        for(auto i: s1){\n            cout << i << " ";\n        }\n        cout << endl;\n        int sum = 0, count = 0;\n        for(auto i: s1){\n            sum+= i;\n            if(sum>maxSum){\n                sum-= i;\n                continue;\n            }\n            count++;\n        }\n        return count;\n    }\n};\n```
['C++']