All prompts are owned by LeetCode. To view the prompt, click the title link above.
First completed : March 12, 2025
Last updated : March 12, 2025
Related Topics : Array, Binary Search, Counting
Acceptance Rate : 74.61 %
class Solution:
def maximumCount(self, nums: List[int]) -> int:
pos = neg = 0
for n in nums :
if n > 0 :
pos += 1
elif n < 0 :
neg += 1
return max(pos, neg)
class Solution:
def maximumCount(self, nums: List[int]) -> int:
return max((pos := sum(x > 0 for x in nums)), len(nums) - nums.count(0) - pos)