← Back to companies
[ OK ] Loaded —
[ INFO ]
$ cd
$ ls -lt
01
02
03
04
05
$ ls -lt
01
02
03
04
05
user@intervues:~/$
Practice/Google/Leetcode 416. Partition Equal Subset Sum
CodingMust
Given an array of positive integers, determine whether it's possible to divide the array into two subsets such that the sum of elements in both subsets is equal.
Your task is to return true if such a partition exists, and false otherwise.
Example 1:
Input: nums = [1, 5, 11, 5] Output: true Explanation: The array can be partitioned as [1, 5, 5] and [11], both with sum 11.
Example 2:
Input: nums = [1, 2, 3, 5] Output: false Explanation: The array cannot be partitioned into two subsets with equal sum. The total sum is 11, which is odd.
Example 3:
Input: nums = [2, 2, 1, 1] Output: true Explanation: The array can be partitioned as [2, 1] and [2, 1], both with sum 3.