JAVA || 100% BEAT || EASY TO UNDERSTAND
IntuitionApproachComplexity
Time complexity:

Space complexity:
Code
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->

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

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

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

# Code
```java []

//USING ARRAY
class Solution {
    public int maxCount(int[] banned, int n, int maxSum) {
        int[] arr=new int[10001];
        for (int j : banned) {
            arr[j]=1;
        }
        int curSum=0;
        int count=0;
        for (int i = 1; i<=n ; i++) {
            if(arr[i]==1) continue;
            curSum+=i;
            if(curSum > maxSum){
                break;
            }
            count++;
        }
        return count;
    }
}

// UISNG HASHSET
class Solution {
    public int maxCount(int[] banned, int n, int maxSum) {
        HashSet<Integer> set=new HashSet<>();
        for(int i: banned){
            set.add(i);
        }
        int count=0;
        int sum=0;
        for(int i=1;i<=n;i++){
            if(set.contains(i)){
                continue;
            }
            sum+=i;
            if(sum > maxSum){
                break;
            }
            count++;
        }
        return count;
    }
}
```
['Java']