Maximum Count of Positive Integer and Negative Integer
Easy
Topics
Given a sorted array nums in non-decreasing order, return the maximum between the number of strictly positive integers and the number of strictly negative integers. Zeros count toward neither. Aim for O(log n).
Example 1
Input: nums = [-2,-1,-1,1,2,3] Output: 3
Example 2
Input: nums = [-3,-2,-1] Output: 3
Example 3
Input: nums = [5,20,66,1314] Output: 4
Constraints
- 1 <= nums.length <= 2000
- -2000 <= nums[i] <= 2000
- nums is sorted in non-decreasing order.
Run ⌘' · Submit ⌘⏎