Skip to main content
Back to problems
Leetcode
Medium
Arrays
Dynamic Programming
Google
Partition Equal Subset Sum

Determine whether an array can be split into two subsets with equal total sum.

Acceptance 0%
Problem Statement

Given a list of positive integers, decide whether it is possible to partition the numbers into two groups such that the sum of the numbers in both groups is the same.

You may use each element at most once, and every element must belong to exactly one of the two groups.

Input Format

  • An integer array nums containing positive integers.

Output Format

  • Return true if the array can be partitioned into two subsets with equal sum.
  • Otherwise, return false.

Constraints

  • 1 <= nums.length
  • All values are positive integers
  • The total sum determines whether an equal split is possible
  • A valid partition must use every element exactly once
Examples
Sample cases returned by the problem API.

Example 1

Input

nums = [1,5,11,5]

Output

true

Explanation

The array can be split into [1, 5, 5] and [11]. Both subsets sum to 11.

Example 2

Input

nums = [1,2,3,5]

Output

false

Explanation

The total sum is 11, which is odd, so it cannot be split into two equal-sum subsets.

Premium problem context

Unlock deeper context for this problem

Premium adds guided hints, editorial links, similar variants, discussion resources, and concept maps so you can understand why a problem matters, not just solve it once.

Guided hints
Editorial and discussion links
Concept map and variants
Sign in to unlock
Track your progress
Sign in to bookmark this problem, save notes, and manage its revision plan.