Smallest, unrepresented integer

Question

Given a sorted (in increasing order) array of positive numbers, can you find the smallest positive integer that cannot be represented as a sum of elements from the array?

Input:  arr[] = [1, 3, 6, 10, 11, 15]
Output: 2

Input:  arr[] = [1, 1, 1, 1]
Output: 5

Input:  arr[] = [1, 1, 3, 4]
Output: 10

Solution will be written in Python.

Solution

Access restricted

Subscribe to premium account to see the solution.

Get premium now