Skip to content
LC-2529 Easy LeetCode

2529. Maximum Count of Positive Integer and Negative Integer

Read the full problem statement on LeetCode.
Difficulty: easy Acceptance: 74% Topics: Array, Binary Search, Counting
View full problem on LeetCode
Reference solution (spoiler · python)
# Time:  O(logn)
# Space: O(1)

import bisect


# binary search
class Solution(object):
    def maximumCount(self, nums):
        """
        :type nums: List[int]
        :rtype: int
        """
        return max(bisect.bisect_left(nums, 0)-0, len(nums)-bisect.bisect_left(nums, 1))

Solution from kamyu104/LeetCode-Solutions · MIT