#K46702. Equal Subset Sum Partition
Equal Subset Sum Partition
Equal Subset Sum Partition
You are given a list of non-negative integers. Your task is to determine whether the list can be partitioned into two subsets such that the sums of the subsets are equal. In other words, if the total sum of the list is \(S\), you need to check if there exists a subset whose sum is \(S/2\).
Note: If the total sum \(S\) is odd, it is impossible to partition the list into two subsets with equal sum.
Input Format: The input is given via standard input. The first line contains an integer \(n\), the number of elements in the list. The second line contains \(n\) space-separated integers.
Output Format: A single line output via standard output: print True
if such a partition exists, otherwise print False
.
inputFormat
The first line of input contains an integer \(n\) (the number of elements). The second line contains \(n\) space-separated integers which represent the elements of the list.
outputFormat
Output a single line: True
if the list can be partitioned into two subsets with equal sums, and False
otherwise.
4
1 5 11 5
True