C++ Simple and Clean Solution, Brief Explanation
Intuition\nStore all the banned numbers smaller than n in a set, so that lookup should take constant time complexity.\nIterate through all numbers from 1 to n, 
# Intuition\nStore all the banned numbers smaller than `n` in a set, so that lookup should take constant time complexity.\nIterate through all numbers from 1 to n, if it\'s not in `banned` - try to add it to `res`. If the `curr_sum` exceeds `maxSum`, return `res`.\n\n# Complexity\n- Time complexity: O(n)\n\n- Space complexity: O(n)\n\n# Code\n```cpp []\nclass Solution {\npublic:\n    int maxCount(vector<int>& banned, int n, int maxSum) {\n        unordered_set<int> ban;\n        int res = 0, curr_sum = 0;\n\n        for (auto num : banned) if (num <= n) ban.insert(num);\n\n        for (int i = 1; i <= n; i++) {\n            if (ban.count(i) == 0) {\n                if (curr_sum + i > maxSum) return res;\n                res++;\n                curr_sum += i;\n            }\n        }\n        return res;\n    }\n};\n```\n\n### Like it? Please UPVOTE :)
['C++']