Facebook Pixel

Equal Subsets

For this question, we give you a set of n numbers and ask if it is possible to arrange the numbers into 2 distinct sets such that the sum of each subset is equal.

Constraints

1 <= n <= 1000

The total sum of all the n numbers will not exceed 5000.

Output true if it is possible to have 2 distinct sets with equal sums and false otherwise.

Examples

Example 1:
Input 1: nums = [1, 2, 3, 4]
Output 1: true
Explanation:

1 + 4 = 2 + 3 = 5

Invest in Yourself
Your new job is waiting. 83% of people that complete the program get a job offer. Unlock unlimited access to all content and features.
Go Pro