Trains the technique from
LeetCode 3875Construct Uniform Parity Array IThis is an original problem, written from a brief that listed the technique, the difficulty, the topics, the function shape and the input bounds — none of that problem's wording, examples, hints or editorials. The link is there so you can map your practice onto the standard set.
Same function shape, different story and different numbers.
Counters are given as nums1, all of them different.
One nudge picks two different counters and adds one to each of them. Nudges may be repeated as often as you like, choosing any pair each time.
Return true when some sequence of nudges leaves every counter odd, or leaves every counter even.
Example 1
Two of the four counters are odd, and two is even, so nudging the two odd ones together leaves all four even.
Example 2
One counter is odd and one is even. A nudge flips both, so there is always exactly one odd counter and neither goal is reachable.
Example 3
Two counters are odd and one is even. Nudging the odd pair leaves all three even.
The editor is preloaded with this. It matches the parent problem's shape, so a solution that works here transfers to a judge unchanged.
def uniform_array(nums1: list[int]) -> bool:public boolean uniformArray(int[] nums1)See the step-by-step animation, the intuition, and clean code in every language — free, no credit card.