C++ Solution!!
\n# Complexity\n- Time complexity:O(n)\n Add your time complexity here, e.g. O(n) \n\n- Space complexity:O(n)\n Add your space complexity here, e.g. O(n) \n\n# 
\n# Complexity\n- Time complexity:O(n)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:O(n)\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 ans=0;\n      unordered_set <int> mp;\n      for(auto n:banned){\n          mp.insert(n);\n      }  \n      for(int i=1; i<=n;i++){\n          if(mp.find(i)==mp.end() && (maxSum-i)>=0){\n              ans++;\n              maxSum=maxSum-i;\n          }\n      }\n      return ans;\n    }\n};\n```
['C++']