educative.io

Educative

Confused with problem statement

Hello, I am confused with the problem statement. Isn’t it impossible for the problem to proceed unless the length of the array is 4+? If we have an array of say [3, 1, 2], how can we partition into 2 subsets where the elements sum is equal? One partition is [3 +1] and [2] for example, but 2 doesn’t have anything to add to in order to check for equality. Thank you!

The correct partition for [3, 1, 2] will be [3] &[1,2]. Both the sets have a sum ‘3’.

Thank you. So sum means “a result of” in this case? Because for [3] its not adding to 0 like [3, 0], since there’s no element 0 to add to it. Edit: For example, I thought there would need to be an element 0 for this case to be valid, that is [3, 1 , 2, 0], solution [3 + 0] = [1 + 2].

Right. It can be taken as ‘sum of all elements of the set’. If a set has only one element, then the sum will be that element.

‘0’ will not be a valid input, as the problem expects only positive numbers.

1 Like

Ah that makes it clear, thank you so much!