This commit is contained in:
parent
22514cfa1a
commit
fb11ede9a9
1 changed files with 14 additions and 0 deletions
|
|
@ -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)
|
||||||
|
|
||||||
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue