O02
Minimum Starting Inventory
Problem Statement & Objective
Determine the minimum initial warehouse stock needed so inventory never drops below zero given daily demand.
Function Signature (Python)
minimum_starting_inventory(moves: list[int]) -> intInput & Output Contract
Output Rule:Negatif olmayan en küçük tam sayı. Liste boşsa 0. Stok hiç eksiye düşmüyorsa 0.
System Constraints
0 <= hareketler.length <= 10^5
-10^6 <= hareketler[i] <= 10^6Example Execution Walkthrough
hareketler = [3, -5, 2, -1]
başlangıç 0 kabul edilirse gün sonu bakiyeleri: 3, -2, 0, -1
en düşük bakiye -2 -> bunu 0'a çıkarmak için +2 gerekir
cevap: 2Example Test Scenarios (3)
Example 1
Input:
[[3,-5,2,-1]]Expected Output:
2Example 2: Başta Negatif Düşüş
Input:
[[-1,-1,-1,5]]Expected Output:
3Example 3: Pozitif Başlangıç
Input:
[[10,-5,-3,2]]Expected Output:
0