Easy JAVA solution using set
Code\njava []\nclass Solution {\n    public int maxCount(int[] banned, int n, int maxSum) {\n        int count=0;\n        HashSet<Integer> set=new HashSet<>();
# Code\n```java []\nclass Solution {\n    public int maxCount(int[] banned, int n, int maxSum) {\n        int count=0;\n        HashSet<Integer> set=new HashSet<>();\n\n        for(int num: banned) {\n            if(num<=n) set.add(num);\n        }\n\n        int sum=0;\n        int num=1;\n        while(num<=n && sum<maxSum && sum+num<=maxSum) {\n            if(!set.contains(num)) {\n                count++;\n                sum+=num;\n            }\n            num++;\n        }\n\n        return count;\n    }\n}\n```
['Java']