Bootcamps
Masterclasses
Menu
Courses
Account
Login / Sign Up

Partition Equal Subset

Easy Acceptance 77% Points 20

The Partition Equal Subset problem requires determining whether a given array of positive integers can be divided into two subsets such that the sum of elements in both subsets is equal. Each element must belong to exactly one subset. The task is to return true if such a partition is possible, otherwise return false.

Examples
Example 1

Example 1

Input: nums = [1,5,11,5]

Output: true

Explanation: The total sum of the array is 22. It can be divided into two subsets with sum 11 each, for example [1,5,5] and [11]. Therefore, equal partition is possible.

Example 2

Example 2

Input: nums = [1,2,3,5]

Output: false

Explanation: The total sum is 11, which is odd. Since it cannot be divided into two equal integer parts, partition is not possible.

Example 3

Example 3

Input: nums = [2,2,1,1]

Output: true

Explanation: The total sum is 6. It can be split into two subsets with sum 3 each, for example [2,1] and [2,1]. Therefore, equal partition exists.

Constraints
  • 1 = n = 200
  • 1 = nums[i] = 100
Topics
Recursion
Companies
Apple
Added 19 Jul 2026 77% acceptance
Ln 1, Col 1Sign in to save your code
1 5 11 5
true