Easiest Solution ✅✅✅ || Beginner Friendly || Beats 99.62 % Runtime 🚀🚀🚀 || C++
Intuition\nThe task is to maximize the count of integers selected from the range [1, n] such that their sum does not exceed maxSum and no integers from the bann
# Intuition\nThe task is to maximize the count of integers selected from the range `[1, n]` such that their sum does not exceed `maxSum` and no integers from the `banned` list are included.\n\nTo solve this:\n- Exclude numbers in the `banned` list.\n- Iteratively select the smallest numbers from the remaining set (as smaller numbers allow adding more integers to the sum).\n\n# Approach\n\n1. **Mark Banned Numbers:**\n\n    - Use a `vector<int>` of size `n + 1` to mark numbers from the `banned` list for quick lookup. Every value which is not in the `banned` list is zero in `vector<int> arr` by default.\n    - If a number is in the `banned` list and within the range `[1, n]`, mark its position as `1` in the array.\n\n2. **Iterate and Calculate:**\n\n    - Iterate through numbers from `1` to `n` while ensuring that:\n        - The number is not in the `banned` list.\n        - Adding the number to the running sum does not exceed `maxSum`.\n        - Increment the counter(`cnt` here) by `1` if such match is found and subtract that number(`i`) from the `maxSum`.\n\n3. Break Early:\n\n    - If a number is greater than `maxSum`, no further numbers can be added.\n    Reason: there is no need to further wait as once a number exceeds the `maxSum`, it is guaranteed that its successors will do the same, so we break early and return the count.\n\n# Complexity\n- **Time complexity:**\n    - Overall: $$O(n+k)$$\n    where k is the size of the `banned` array :)\n- **Space complexity:**\n$$O(n)$$, for making the `vector<int> arr`\n\n# Code\n```cpp []\nclass Solution {\npublic:\n    int maxCount(vector<int>& banned, int n, int maxSum) {\n        vector<int> arr(n+1,0);\n        for(int i: banned){\n            if(i<=n)\n                arr[i]=1;\n        }\n        int cnt=0;\n        for(int i=1;i<=n && maxSum>0;i++){\n            if(i<=maxSum && arr[i]!=1){\n                maxSum-=i;\n                cnt++;\n            } else if(arr[i]!=1) break;\n        }\n        return cnt;\n    }\n};\n```
['C++']