Partition Equal Subset Sum
Given an integer array nums, determine whether you can partition the array into two subsets such that the sum of the elements in both subsets is equal.
Return true if such a partition is possible, otherwise return false.
Example 1
Input
nums = [1, 5, 11, 5]
Output
true
Explanation
The array can be partitioned into:
[1, 5, 5] = 11
[11] = 11
Both subsets have the same sum.
Example 2
Input
nums = [1, 2, 3, 5]
Output
false
Explanation
The total sum is 11, which is odd.
Therefore, it is impossible to divide the array into two subsets having equal sums.
Constraints
Hints:
Hint 1
First calculate the total sum of all elements.
If the total sum is odd, an equal partition is impossible.
Hint 2
If the total sum is even, the problem becomes:
Can we find a subset whose sum is totalSum / 2?
Author & Technical Reviewer
Technically reviewed by: ExamAdda Technical Review Team
Technical Reviewers, ExamAdda
Software engineers at ExamAdda who check every article's definitions, complexity claims and code examples before and after publishing.
Published
Aug 26, 2026
Last updated
Aug 26, 2026
Content Verification Methodology
Definitions and complexity claims were checked against authoritative computer-science references. Code examples were compiled and tested with standard, boundary and edge-case inputs.
Expected Output