Skip to content

Commit a84cd5e

Browse files
committed
Create 2529-MaximumCountOfPositiveIntegerAndNegativeInteger.cpp
1 parent a827cf4 commit a84cd5e

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
class Solution {
2+
public:
3+
int maximumCount(vector<int>& nums) {
4+
int n = nums.size();
5+
int neg(0), z(0);
6+
for(int p = 0; p < nums.size(); p++){
7+
if(nums[p] < 0){++neg;}
8+
else if(nums[p] == 0){++z;}
9+
else{break;}
10+
}
11+
12+
int pos = n - z - neg;
13+
return (neg > pos ? neg : pos);
14+
}
15+
};

0 commit comments

Comments
 (0)