Simple Solution - O(n) Time Complexity
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ --> O(n)\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ --> O(1)\n\n# Code\n```cpp []\nclass Solution {\npublic:\n    int maxCount(vector<int>& banned, int n, int maxSum) {\n        int ans = 0;\n        int sum = 0;\n        int i=1;\n\n        while(i<=n) {\n            auto it = find(banned.begin(), banned.end(), i);\n\n            if(it == banned.end()) {\n\n                if(sum+i > maxSum) { \n                    break;\n                }\n                sum += i;\n                ans++;\n            }\n            i++;\n        }\n\n        return ans;\n    }\n};\n```
['C++']