Easy | Python Solution | Sort
Code\n\nclass Solution:\n    def maxCount(self, banned: List[int], n: int, maxSum: int) -> int: \n        all_arr = [i for i in range(1, n+1)]\n        res = li
# Code\n```\nclass Solution:\n    def maxCount(self, banned: List[int], n: int, maxSum: int) -> int: \n        all_arr = [i for i in range(1, n+1)]\n        res = list(set(all_arr) - set(banned))\n        res.sort()\n        currSum = sum(res)\n        ans = len(res)\n        while currSum > maxSum:\n            currSum -= res.pop()\n            ans -= 1\n        return ans\n              \n```\nDo upvote if you like the Solution :)
['Python3']