Tap here to switch tabs
Problem
Submissions

Problem: Make the Prefix Sum Non-negative

med
30 min
Try to solve the Make the Prefix Sum Non-negative problem.

Statement

You are given an integer array nums indexed from 00. In one operation, you can choose any element of nums and move it to the end of the array.

Return the minimum number of operations required so that every prefix sum of nums is greater than or equal to 00.

Note: The test cases are generated such that it is always possible to make all prefix sums greater than or equal to 00.

Constraints:

  • 1≤1 \leq nums.length ≤105\leq 10^5

  • −109≤-10^9 \leq nums[i] ≤109\leq 10^9

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Make the Prefix Sum Non-negative

med
30 min
Try to solve the Make the Prefix Sum Non-negative problem.

Statement

You are given an integer array nums indexed from 00. In one operation, you can choose any element of nums and move it to the end of the array.

Return the minimum number of operations required so that every prefix sum of nums is greater than or equal to 00.

Note: The test cases are generated such that it is always possible to make all prefix sums greater than or equal to 00.

Constraints:

  • 1≤1 \leq nums.length ≤105\leq 10^5

  • −109≤-10^9 \leq nums[i] ≤109\leq 10^9