diff --git a/easy/maximum_count_of_positive_integer_and_negative_integer.py b/easy/maximum_count_of_positive_integer_and_negative_integer.py new file mode 100644 index 0000000..c32c891 --- /dev/null +++ b/easy/maximum_count_of_positive_integer_and_negative_integer.py @@ -0,0 +1,14 @@ +# https://leetcode.com/problems/maximum-count-of-positive-integer-and-negative-integer + +import bisect +from typing import List + +class Solution: + def maximumCount(self, nums: List[int]) -> int: + pos = neg = bisect.bisect_left(nums, 0) + while pos < len(nums) and nums[pos] <= 0: + pos += 1 + pos = len(nums) - pos + return max(pos, neg) + +