Back to Month
EASY 02 Sep 2026 View on LeetCode

3875. Construct Uniform Parity Array I

</> Solution

class Solution {
    public boolean uniformArray(int[] nums1) {
        int oddCount = 0, evenCount = 0;
        for (int x : nums1) {
            if (x % 2 == 0) evenCount++;
            else oddCount++;
        }

        boolean allEven = (oddCount == 0 || oddCount >= 2);
        boolean allOdd = (evenCount == 0 || oddCount >= 1);
        return allEven || allOdd;
    }
}

TIME COMPLEXITY

O(n)

SPACE COMPLEXITY

O(1)

TOPICS

Array Greedy Math Parity