Skip to main content

Partition Equal Subset Sum

MediumPremium

Given an array of integers, determine if it can be partitioned into two subsets such that the sum of the elements in each subset is equal.

A partition is considered valid if it divides the array into two subsets where both subsets have the same sum.

Examples

Input: [2, 4, 11, 5] Output: True Explanation: The array can be partitioned into two subsets [2, 4, 5] and [11] with equal sum. Input: [2, 7, 3, 1] Output: False Explanation: The array cannot be partitioned into two subsets with equal sums.