Diwali Offer!Flat 20% OFF
Enroll Now
PrakalpanaLive online tech training

173. Partition Equal Subset Sum

MediumDay 51 of 60Dynamic Programming

Given an array of positive integers nums, return true if you can split it into two subsets whose sums are equal, and false otherwise. Every element must go into exactly one of the two subsets.

Example 1
Input: nums = [1,5,11,5]
Output: true
[1,5,5] and [11] both sum to 11.
Example 2
Input: nums = [1,2,3,5]
Output: false
The total is 11, which is odd, so it cannot be split evenly.
Constraints
  • 1 <= nums.length <= 200
  • 1 <= nums[i] <= 100
Hints
Frequently asked at: Amazon, Meta, Google
Ctrl + Enter runs the examples

Not sure what to learn next?

A 1-on-1 session with an industry mentor and a roadmap built for you. How it works

  1. 1Discuss your goals
  2. 2Get a personal plan
  3. 3Start learning
Book for β‚Ή200/ 30 min