LeetCode Courses 3875. Construct Uniform Parity Array I
LeetCode

3875. Construct Uniform Parity Array I

We iterate from a parity case-analysis to a one-line solution. The "prove it's always possible, then return True" pattern crops up in more LeetCode problems than you'd think.

1 chapter Beginner Written walk-through Updated 21 May 2026 Phil · @FirnoxGames
Free

Free for everyone. No account needed.

Start reading →

What you'll learn

1 3875. Construct Uniform Parity Array I 📖 5 min read

We iterate from a parity case-analysis to a one-line solution. The "prove it's always possible, then return True" pattern crops up in more LeetCode problems than you'd think.

In this chapter
  1. Problem
  2. Problem analysis
  3. Constructing a solution
  4. Solution

Problem

You are given an array nums1 of n distinct integers.

You want to construct another array nums2 of length n such that the elements in nums2 are either all odd or all even.

For each index i, you must choose exactly one of the following (in any order):

  • nums2[i] = nums1[i]
  • nums2[i] = nums1[i] - nums1[j], for an index j != i

Return true if it is possible to construct such an array, otherwise return false.

Included with this course
📖Written version of every chapter