Easy

Maximum Count of Positive Integer and Negative IntegerC++

Full explanation · Time O(logn) · Space O(1)

// Time:  O(logn)
// Space: O(1)

// binary search
class Solution {
public:
    int maximumCount(vector<int>& nums) {
        return max(
            distance(cbegin(nums), lower_bound(cbegin(nums), cend(nums), 0)),
            distance(lower_bound(cbegin(nums), cend(nums), 1),  cend(nums))
        ); 
    }
};