Skip to content

Latest commit

 

History

History
45 lines (34 loc) · 1.21 KB

_2529. Maximum Count of Positive Integer and Negative Integer.md

File metadata and controls

45 lines (34 loc) · 1.21 KB

All prompts are owned by LeetCode. To view the prompt, click the title link above.

Back to top


First completed : March 12, 2025

Last updated : March 12, 2025


Related Topics : Array, Binary Search, Counting

Acceptance Rate : 74.61 %


Solutions

Python

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)