#C13984. Equal Sum Partition
Equal Sum Partition
Equal Sum Partition
You are given an array of non-negative integers. Your task is to determine whether the array can be partitioned into two subsets such that the sum of elements in both subsets is equal. Formally, if the array is represented as \(nums = [nums_1, nums_2, \dots, nums_n]\), check if there exists a subset \(S \subseteq \{1,2,\dots,n\}\) such that
\(\sum_{i \in S} nums_i = \sum_{i \notin S} nums_i\).If this condition is met, output True
; otherwise, output False
.
inputFormat
The input is given via standard input. The first line contains an integer (n) representing the number of elements in the array. The second line contains (n) space-separated non-negative integers.
outputFormat
Output a single line to standard output containing True
if the array can be partitioned into two subsets with equal sum, and False
otherwise.## sample
4
1 5 11 5
True