You are given an array nums1 of n distinct integers. Build an array nums2 of length n whose elements are all odd or all even. For each index i, choose exactly one option: nums2[i] = nums1[i], or nums2[i] = nums1[i] - nums1[j] for some index j != i. Return true if such an array can be built, otherwise false.
You are given an array nums1 of n distinct integers. Build an array nums2 of length n whose elements are all odd or all even. For each index i, choose exactly one option: nums2[i] = nums1[i], or nums2[i] = nums1[i] - nums1[j] for some index j != i. Return true if such an array can be built, otherwise false.
Example 1:
Input: {"nums1":[2,3]}
Output: true
Constraints:
1≤n=nums1.length≤100
1≤nums1[i]≤100
nums1 consists of distinct integers.
Test Cases
Input (Stdin)
Expected Output (Stdout)
Execution Result
Run code to see results.
Input
arr ={"nums1":[2,3]}
2 distinct numbers: 1 odd, 1 even. Each slot may keep its value or subtract another element.