First negative balance day
A small shop tracks its account with a starting balance and a list of daily net changes (sales minus expenses, possibly negative). Applying the changes in order, return the 1-based day number on which the balance first drops below zero, or -1 if it never does. Example: start 10 with changes [-4, -5, -3] goes 6, 1, -2, so the answer is day 3.
Implement
first_shortfall_day(start: int, changes: list[int]) → intExamples
in
[10,[-4,-5,-3]]out3What a strong answer looks like
State your approach and its time/space complexity out loud before you optimize. Handle the edge cases (empty input, duplicates, overflow), and say why you chose this over the brute force. Green tests are the floor, not the grade.
0:00 of about 12 min
solution.py
InputExpectedGot
[10,[-4,-5,-3]]3not run yetsample