Given a sorted array A (sorted in non-decreasing order) of N positive numbers.
Find the smallest positive integer value that cannot be represented as sum of elements of any subset of given set.
NOTE: If answer exceeds the range of on an Integer datatype i.e 2147483647 then return 2147483647.
First and only argument represents an integer array of size N denoting A.
Return an single integer denoting smallest positive integer value that cannot be represented as sum of elements of any subset of given set.
A = [1, 1, 1, 1]
A = [1, 2, 5, 10, 20, 40]
Sum = 1, 2, 3, 4 is easily possible with given elements but a subset with sum of 5 is not present in the given array.
Sum = 4 is not possible and is the smallest so this will be the answer.
NOTE: You only need to implement the given function. Do not read input, instead use the arguments to the function. Do not print the output, instead return values as specified. Still have a doubt? Checkout Sample Codes for more details.