Logo
Grokking Dynamic Programming Patterns for Coding Interviews
Ask Author
Back to course home

0% completed

Equal Subset Sum Partition

Problem Statement

Given a set of positive numbers, find if we can partition it into two subsets such that the sum of elements in both the subsets is equal.

Example 1:

Input: {1, 2, 3, 4}
Output: True
Explanation: The given set can be partitioned into two subsets with equal sum: {1, 4} & {2, 3}

Example 2:

Input: {1, 1, 3, 4, 7}
Output: True
Explanation: The given set can be partitioned into two subsets with equal sum: {1, 3, 4} & {1, 7}

Example 3:

Input: {2, 3, 4, 6}
Output: False
Explanation: The given set cannot be partitioned into two subsets with equal sum.

Constraints:

  • 1 <= num.length <= 200
  • 1 <= num[i] <= 100

Try it yourself

This problem looks similar to the 0/1 Knapsack problem, try solving it before moving on to see the solution:

Python3
Python3

. . .
Mark as Completed