701. Odd Subsets
Given an array of unique elements nums, return all subsets of nums whose elements sum up to an odd value.
A subset of an array is any selection of its elements, including the empty set. Answers can be returned in any order.
Example 1:
Input: nums = [1, 2, 3, 4]
Output: [[1], [1, 2], [1, 2, 4], [1, 4], [2, 3], [2, 3, 4], [3], [3, 4]]
Explanation: all these subsets have an odd sum value.
Example 2:
Input: nums = [1, 3, 5, 7]
Output: [[1], [1, 3, 5], [1, 3, 7], [1, 5, 7], [3], [3, 5, 7], [5], [7]]
Explanation: all these subsets have an odd sum value.
Still unsure what the problem is asking ?
Let’s go through a few more examples, step by step, to make it clearer.
Constraints:
- 1 <= nums.length <= 10
- -104 <= nums[i] <= 104
- All elements are unique