Best Approach without any Extra space || O(nlogn) andO(1) space
Intuition\n> - please upvote if u like it \n- first of all sort the array and find all the missing number betwwen 1 to n\n- so run a loop and search the number 
# Intuition\n> - please upvote if u like it \n- first of all sort the array and find all the missing number betwwen 1 to n\n- so run a loop and search the number b/w 1 to n\n- by using binary search\n- if not found in the array than sum it into the a variable and increase ur ans by 1 after checking that existing sum is less than the given max sum\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n- sort thr array\n- take 2 variable sum=0 and ans =0\n- and run a loop from 1 to n \n- by using binary search find the numbers \n- if(sum+i<= maxsum) increase the ans by 1\n- and update sum as sum+i;\n- and at last return the ans\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity: O(nlogn)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:O(1)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\npublic:\n    int maxCount(vector<int>& banned, int n, int maxSum) {\n        int cnt=0,sum=0;\n        sort(banned.begin(),banned.end());\n        for(int i=1;i<=n;i++){\n            bool ans = binary_search(banned.begin(),banned.end(),i);\n            if(ans) continue;\n            else{\n                if(sum+i<=maxSum){\n                    cnt++;\n                    sum+=i;\n                }\n            }\n        }\n        return cnt;\n    }\n};\n```
['Binary Search', 'Sorting', 'C++']