Algorithm · Confluent · Easy
Given an integer array nums, determine the smallest positive integer x such that, after beginning with x and adding the elements of nums in order, every running total remains positive. Input: An integer array nums. Output: The integer x. Example 1: Explanation: Beginning with x = 5 gives the running totals 5, 2, 4, 1, 5, 7 — every one of them positive. Starting from x = 4 would give 4, 1, 3, 0, so 4 is too small; 5 is the smallest valid start. Example 2: Explanation:…
Checking your access…