✅✅Beginner Friendly Beasts 59%✅✅
Intuition\n Describe your first thoughts on how to solve this problem. \nbeginner Friendly Answer\n\n\n# Approach\n Describe your approach to solving the proble
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nbeginner Friendly Answer\n\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n2 Pointer\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n$O(logn*n)$\n\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n$O(1)$\n\n# Code\n```java []\nclass Solution {\n    public int maxCount(int[] banned, int n, int maxSum) {\n        \n        Arrays.sort(banned);\n        int cnt = 0;\n        int j = 0;\n        int sum = 0;\n        int bn = banned.length;\n        for(int i = 1 ; i <= n ; i++){\n            \n            if(j < bn && banned[j] == i ){\n                j++;\n            }\n            else {\n                sum+=i;\n                if(sum > maxSum){\n                    return cnt;\n                }\n                cnt++;\n            }\n            while(j < bn && banned[j] <= i){\n                j++;\n            }\n            \n            \n        }\n        return cnt;\n        \n    }\n}\n```
['Array', 'Greedy', 'Sorting', 'Java']