Simple and best solution using set 
Complexity
Time complexity:O(N)

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

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

# Code
```python3 []
class Solution:
    def maxCount(self, banned: List[int], n: int, maxSum: int) -> int:
        d=set(banned)
        sumi=0
        cnt=0
        for i in range(1,n+1):
            if i in d:
                continue
            if maxSum>=sumi+i:
                sumi+=i
                cnt+=1
        return cnt
```
['Array', 'Hash Table', 'Binary Search', 'Greedy', 'Sorting', 'Ordered Set', 'Python3']