Search⌘ K
AI Features

Partition Equal Subset Sum

Explore dynamic programming techniques to solve the Partition Equal Subset Sum problem by determining if a given array can be divided into two subsets with equal sums. Understand constraints, apply memoization or tabulation methods, and practice implementing solutions to strengthen your coding interview skills.

Statement

Given a non-empty array of positive integers, determine if the array can be divided into two subsets so that the sum of both subsets is equal.

Constraints:

  • 11 \leq nums.length 200\leq 200
  • 11 \leq nums[i] 100\leq 100

Examples

Understand the problem

Let’s take a moment to make sure you’ve correctly understood the problem. The quiz below helps you check if you’re solving the correct problem:

Partition Equal Subset Sum

1.

What is the output if the array [1, 2, 5, 2] is given as input?

A.

TRUE

B.

FALSE


1 / 4

Figure it out!

We have a game for you to play. Rearrange the logical building blocks to develop a clearer understanding of how to solve this problem.

Sequence - Vertical
Drag and drop the cards to rearrange them in the correct sequence.

1
2
3
4
5

Try it yourself

Implement your solution in the following coding playground:

Java
usercode > PartitionEqualSum.java
import java.util.*;
public class PartitionEqualSum{
public static boolean canPartitionArray(int[] arr) {
// Replace this placeholder return statement with your code
return false;
}
}
Partition Equal Subset Sum