Partition Equal Subset Sum
Explore how to use dynamic programming to solve the Partition Equal Subset Sum problem. Learn to divide an array into two subsets with equal sums by applying memoization and tabulation methods. This lesson helps you develop a practical approach to optimizing complex problems using these dynamic programming strategies.
We'll cover the following...
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:
-
nums.length -
nums[i]
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
What is the output if the array [1, 2, 5, 2] is given as input?
TRUE
FALSE
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.
Try it yourself
Implement your solution in the following coding playground:
package mainfunc canPartitionArray(nums []int) bool {// Replace this placeholder return statement with your codereturn false}