leetpycode/easy/maximum_count_of_positive_integer_and_negative_integer.py

14 lines
375 B
Python

# 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)