Example -
Let's say array is {3, -1, 8, 12, 10} then it should return 1 as array elements {3, -1, 10} sums upto max element which is 12
So conditions are -
- Array elements that sums up to max. element need not to be continuous.
- Array is not sorted
- It contains negative numbers
I can do it in brute force way but I am pretty sure there exists a more efficient solution, possibly O(N) solution.