set and greedy approach simple solution c++
IntuitionApproachComplexity
Time complexity:
o(N)

Space complexity:
O(M) array size
Code
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->

# Approach
<!-- Describe your approach to solving the problem. -->

# Complexity
- Time complexity:
- o(N)
<!-- Add your time complexity here, e.g. $$O(n)$$ -->

- Space complexity:
- O(M) array size 
<!-- Add your space complexity here, e.g. $$O(n)$$ -->

# Code
```cpp []
class Solution {
public:
    int maxCount(vector<int>& banned, int n, int maxSum) {
    // binary search ,set,
    unordered_set<int> s(banned.begin(), banned.end());
    int sum=0;
    int ans=0;
    for (int i=1;i<=n ;i++){
        if (s.find(i)==s.end()){
            sum=sum+i;
            if (sum> maxSum ){
                return ans;
            }
            ans++;
        }
    }
    return ans;

        
    }
};
```
['C++']