Skip to content

Latest commit

 

History

History
25 lines (21 loc) · 560 Bytes

Question_2529.md

File metadata and controls

25 lines (21 loc) · 560 Bytes

LeetCode Records - Question 2529 Maximum Count of Positive Integer and Negative Integer

Attempt 1: Use a loop

class Solution {
    public int maximumCount(int[] nums) {
        int negCount = 0;
        int posCount = 0;

        for (int num : nums) {
            if (num > 0) {
                posCount++;
            } else if (num < 0) {
                negCount++;
            }
        }

        return Math.max(negCount, posCount);
    }
}
  • Runtime: 0 ms (Beats: 100.00%)
  • Memory: 44.92 MB (Beats: 25.87%)