How to optimally divide an array into two subarrays so that sum of elements in both subarrays is same, otherwise give an error?
Given the array>
This is called partition problem. There are optimal solutions for some special cases. However, in general, it is an NP-complete problem.