BackmediumArrays arrays medium

Equal Partition Array Solution

Problem Statement

Given a non-empty array of integers, determine if it is possible to partition the array into two groups with equal sum.

Example 1
Input
[1, 5, 11, 5]
Output
0

Explanation: The array can be partitioned into two groups with equal sum: [1, 11] and [5, 5].

Constraints

  • The input array is non-empty and contains only integers.
  • The sum of all elements in the array is even.
  • If the sum of all elements is zero, the array can be partitioned into two groups with equal sum (each group containing all elements).
  • Otherwise, each group should contain at least one element.
  • The array can be partitioned into two groups with equal sum even if some elements appear multiple times.
Live Compiler
Loading...
Test Cases & Output
🔒 Sign up to run your code

🚀 Practice this problem

Run code, get AI hints & track streak

Sign Up Free