PROPELLD Off-Campus OA (2024) | Problem Minimum Value to Get Positive Step-by-Step Sum
Question · Posted Jun 2026
Problem Statement Given an integer array nums, find the minimum positive integer startValue such that when you start with startValue and add the elements of nums one by one, the running sum never becomes less than 1. Formally: runningSum = startValue runningSum += nums[0] runningSum += nums[1] ... runningSum += nums[n-1] At every step: runningSum >= 1 Return the minimum possible startValue. Example 1 Input nums = [-3,2,-3,4,2] Output 5 Explanation Using startValue = 5: 5 + (-3) = 2 ...
The full answer & interview discussion are available to premium members.
Log in Create a free account