03.09.2026
3876. Construct Uniform Parity Array II medium
https://dmitrysamoylenko.com/leetcode/
Join me on Telegram
https://t.me/leetcode_daily_unstoppable/1471
Problem TLDR
Can make all even/odd by subtracting any smaller
Intuition
Subtracting the odd converts everything to odd. We have to have the smallest odd to subtract from any other.
Approach
* write the most explicit code, then shrink whats irrelevant
Complexity
Time complexity: O(n)
Space complexity: O(1)
Code
fun uniformArray(n: IntArray) =
n.all{it%2<1} || n.min()%2>0 pub fn uniform_array(n: Vec<i32>) -> bool {
n.iter().all(|x|x&1<1)||n.iter().min().unwrap()&1>0
}

