Skip to interview prep
Apexed
Problem list105 / 125

105. Partition Into Two Equal-Sum Subsets

MediumDynamic programming

Return true if the positive integers in nums can be split into two groups with equal sums. Every number must go in exactly one group.

Example 1

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

Example 2

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

Constraints

  • 1 ≤ nums.length ≤ 200
  • 1 ≤ nums[i] ≤ 100

Tab indents · Ctrl/⌘ + Enter runs · Esc then Tab leaves the editor

Run checks these cases; the expected output comes from the reference solution. Submit judges all 5 hidden and sample tests.

Code runs only in your browser in an isolated sandbox. Progress and submissions are saved on this device.

Partition Into Two Equal-Sum Subsets — coding interview practice — Apexed