💯Very Easy Detailed Solution || 🎯 Binary Search
Approach\n Describe your approach to solving the problem. \n1. Binary Search Helper Function (isPresent):\n    - This function checks whether a given number k i
# Approach\n<!-- Describe your approach to solving the problem. -->\n1. **Binary Search Helper Function (isPresent):**\n    - This function checks whether a given number k is present in the banned array using a binary search.\n    - The banned array is sorted before using this function.\n\n2. **Core Function (maxCount):**\n    - **Sort the banned array**: This ensures the array is ready for binary search.\n    - **Iterate through numbers from 1 to n**:\n        - For each number i, check if it\'s not present in the banned array using the isPresent function.\n        - If the number is not in banned, check if adding it to the current sum does not exceed maxSum.\n            - If it fits, include it in the sum and increment the count.\n            - If it exceeds maxSum, break the loop as further numbers will only increase the sum.\n        - Return the count of numbers added to the sum.\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n$O(l.log(l)) + O(n.log(l))$\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n$O(l)$\n# Code\n```java []\nclass Solution {\n    public boolean isPresent(int arr[], int k){\n        int low=0, high=arr.length-1;\n        while(low <= high){\n            int mid = low + (high - low)/2;\n            if(arr[mid] == k){\n                return true;\n            }\n            else if(arr[mid] < k){\n                low = mid + 1;\n            }\n            else{\n                high = mid - 1;\n            }\n        }\n        return false;\n    }\n    public int maxCount(int[] banned, int n, int maxSum) {\n        Arrays.sort(banned);\n        int l = banned.length;\n        int i=1, sum=0, count=0;\n        while(i <= n){\n            if(!isPresent(banned, i)){\n                if(sum + i <= maxSum){\n                    sum += i;\n                    count++;\n                }\n                else break;\n            }\n            i++;\n        }\n        return count;\n    }\n}\n```
['Array', 'Math', 'Binary Search', 'Greedy', 'Counting', 'Java']