Balanced Partition Checker
easy
Dynamic ProgrammingArrayDp Knapsack
Asked atAmazonGoogleMetaMicrosoft
Problem Description
Given an array of positive integers `values`, determine whether it is possible to split the array into two non-empty subsets such that the sum of elements in both subsets is equal.
Return `true` if such a partition exists, otherwise return `false`.
**Example 1:**
```
Input: values = [3, 1, 4, 2, 2]
Output: true
Explanation: [3, 1, 2] sums to 6 and [4, 2] sums to 6.
```
**Example 2:**
```
Input: values = [7, 3, 2]
Output: false
Explanation: Total sum is 12, but no equal partition exists.
```
Constraints
- 2 <= values.length <= 200
- 1 <= values[i] <= 100
Follow-up
Can you solve this problem if each element can be used an unlimited number of times (unbounded knapsack variant)?
Hints
Try the problem first. If you get stuck, you can reveal hints one at a time.
Solution
Leaderboard
No entries yet for python.
Be the first — submit an accepted solution.