1 minute read

Given a list of positive integers nums, return whether you can divide the list into two groups a and b such that:

  • The sum of a and the sum of b are equal.
  • Every number in a is strictly less than every number in b.

Constraints

  • 1 ≤ n ≤ 100,000 where n is the length of nums.

https://binarysearch.com/problems/Set-Split

Examples

Example 1

Input

  • nums = [9, 9]

Output

  • answer = False

Explanation

We can have a = [9] and b = [9] but it doesn’t meet this criteria: “Every number in a is strictly less than every number in b.”

Example 2

Input

  • nums = [4, 9, 5]

Output

  • answer = True

Explanation

We can have a = [4, 5] and b = [9] and both of their sums are 9.

Solution

Categories:

Updated:

Leave a comment