Tap here to switch tabs
Problem
Submissions

Problem: Construct Uniform Parity Array I

Try to solve the Construct Uniform Parity Array I problem.

Statement

You are given an array of distinct integers nums1 of length n.

You want to construct an array nums2 of length n. For each index i from 00 to n - 1, you can choose either:

  • nums2[i] = nums1[i]

  • nums2[i] = nums1[i] - nums1[j] for some index j such that 0≤j<n0 \leq j < n and j≠ij \neq i

Return true if it is possible to create an array nums2 such that all its elements have the same parity (all even or all odd), and false otherwise.

Constraints:

  • 1≤1 \leq n ==== nums1.length ≤100\leq 100

  • 1≤1 \leq nums1[i] ≤100\leq 100

  • nums1 consists of distinct integers.

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Construct Uniform Parity Array I

Try to solve the Construct Uniform Parity Array I problem.

Statement

You are given an array of distinct integers nums1 of length n.

You want to construct an array nums2 of length n. For each index i from 00 to n - 1, you can choose either:

  • nums2[i] = nums1[i]

  • nums2[i] = nums1[i] - nums1[j] for some index j such that 0≤j<n0 \leq j < n and j≠ij \neq i

Return true if it is possible to create an array nums2 such that all its elements have the same parity (all even or all odd), and false otherwise.

Constraints:

  • 1≤1 \leq n ==== nums1.length ≤100\leq 100

  • 1≤1 \leq nums1[i] ≤100\leq 100

  • nums1 consists of distinct integers.