Set Split
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 ofb
are equal. - Every number in
a
is strictly less than every number inb
.
Constraints
1 ≤ n ≤ 100,000
wheren
is the length ofnums
.
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
.
Leave a comment