#K62877. Partition Array with Equal Subset Sum
Partition Array with Equal Subset Sum
Partition Array with Equal Subset Sum
Given an array of integers, determine whether it is possible to partition the array into two subsets such that the sum of the elements in both subsets is equal. In other words, check if there exists a subset whose sum is \(\frac{\sum nums}{2}\) (provided that \(\sum nums\) is even). If such a partition exists, output True
; otherwise, output False
.
You need to read the input from standard input (stdin) and write the output to standard output (stdout). Use appropriate dynamic programming techniques to solve the problem efficiently.
inputFormat
The input is provided via standard input. The first line contains a single integer \(n\) which represents the number of elements in the array. The second line contains \(n\) space-separated integers denoting the elements of the array.
outputFormat
Output a single line to standard output. Print True
if the array can be partitioned into two subsets with equal sum; otherwise, print False
.
4
1 5 11 5
True