Smallest Integer Not Representable as Subset Sum
Given a non-decreasing sorted array ARR
of N
positive numbers, determine the smallest positive integer that cannot be expressed as the sum of elements from any proper subset of the array.
Example:
Input:
ARR = [1, 1, 3]
Output:
6
Explanation:
The possible sums of subsets are:
1 → [1]
2 → [1, 1]
3 → [3]
4 → [1, 3]
5 → [1, 1, 3]
The smallest integer not representable as a subset sum is 6.
Constraints:
1 <= T <= 100
1 <= N <= 10^4
0 <= arr[i] <= 10^9
Be the first one to answer
Add answer anonymously...
Top Delhivery Software Developer interview questions & answers
Popular interview questions of Software Developer
Stay ahead in your career. Get AmbitionBox app
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+
Reviews
4 L+
Interviews
4 Cr+
Salaries
1 Cr+
Users/Month
Contribute to help millions
Get AmbitionBox app