Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit d3385e9

Browse files
Maximum Count of Positive Integer and Negative Integer
1 parent f140472 commit d3385e9

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
""" https://leetcode.com/problems/maximum-count-of-positive-integer-and-negative-integer/ """
2+
3+
class Solution:
4+
def maximumCount(self, nums):
5+
negatives = 0
6+
positives = 0
7+
8+
for num in nums:
9+
if (num < 0):
10+
negatives += 1
11+
elif (num > 0):
12+
positives += 1
13+
14+
if (negatives > positives):
15+
return negatives
16+
else:
17+
return positives
18+
19+
print(Solution().maximumCount([-2,-1,-1,1,2,3]))

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /