100% faster than other's runtime with 4 ms.
\n\n\n# Complexity\n- Time complexity: O(N)\n Add your time complexity here, e.g. O(n) \n\n# Code\njava []\nclass Solution {\n    public int maxCount(int[] bann
![Screenshot 2024-12-06 101151.png](https://assets.leetcode.com/users/images/2d94d4ac-d080-41fe-ac48-981c8b26d03c_1733460153.3206904.png)\n\n\n# Complexity\n- Time complexity: O(N)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```java []\nclass Solution {\n    public int maxCount(int[] banned, int n, int maxSum) {\n        int[] arr=new int[10001];\n        for(int i=0; i<banned.length; i++){\n            arr[banned[i]]=1;\n        }\n\n        long sum=0;\n        int cnt=0;\n        for(int i=1; i<=n; i++){\n            if(arr[i]==1){continue;}\n            sum+=i;\n            if(sum>maxSum){\n               break;\n            }\n            cnt++;\n        }\n\n        return cnt;\n    }\n}\n```
['Java']