Partition Equal Subset Sum

Dynamic Programming, problem 8 of 9

Partition Equal Subset Sum

Medium

LC #416

0/1 knapsacksubset sum

Not attempted yet

Return True if nums can be split into two groups (every number in exactly one group) whose sums are equal.

Example 1

Input: nums = [1, 5, 11, 5]
Output: True
[1, 5, 5] and [11]

Example 2

Input: nums = [1, 2, 3, 5]
Output: False

Example 3

Input: nums = [3, 3, 3, 4, 5]
Output: True
[3, 3, 3] and [4, 5]

Constraints

  • 1 ≤ len(nums) ≤ 200
  • 1 ≤ nums[i] ≤ 100

Python

Loading draft…

Test results

9 tests available

No results yet

Run tests your code against the examples; Submit runs the hidden tests too.

3 examples, 6 hidden

Run examples, then submit all tests.