Grokking Data Structures & Algorithms for Coding Interviews
0% completed
Maximum Count of Positive Integer and Negative Integer (easy)
Problem Statement
Given an array nums sorted in increasing order, return the maximum between the count of positive integers and the count of negative integers.
Note: 0 is neither positive nor negative.
Examples
Example 1:
- Input: nums =
[-4, -3, -1, 0, 1, 3, 5, 7] - Expected Output:
4 - Justification: The array contains three negative integers (-4, -3, -1) and four positive integers (1, 3, 5, 7). The maximum count between negatives and positives is 4.
Example 2:
- Input: nums =
[-8, -7, -5, -4, 0, 0, 0]
.....
.....
.....
Like the course? Get enrolled and start learning!