Maximum Count of Positive Integer and Negative Integer Problem & Solution

See the maximum count of positive integer and negative integer problem on LeetCode.

C++ Solution

#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")

static const int _=[](){ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);return 0;}();

class Solution {
  int maximumCount(vector<int>& nums) {
    auto negit = upper_bound(nums.begin(), nums.end(), -1);
    auto posit = lower_bound(nums.begin(), nums.end(), 1);

    int neg = distance(nums.begin(), negit);
    int pos = distance(posit, nums.end());

    return max(neg, pos);

Start Here

Many paths, there are. Follow yours, you must.