## 題解 ### 鎖定負數的右邊界,正數的左邊界 ```python= class Solution: def maximumCount(self, nums: List[int]) -> int: n = len(nums) def binary_search(bound: bool): # true p, false n nonlocal n,nums left, right = 0, n - 1 output = 0 while left <= right: mid = left + (right - left) // 2 if nums[mid] == 0: # 0 不算,正常略過即可 if bound: left = mid + 1 else: right = mid - 1 elif nums[mid] < 0: if not bound: output = mid + 1 left = mid + 1 elif nums[mid] > 0: if bound: output = n - mid right = mid - 1 return output n_bound = binary_search(False) p_bound = binary_search(True) return max(n_bound,p_bound) ```