Code Room
CodingEasy
Question
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.
Learn the concepts
Vibe coding: describe the solution in plain language (or narrate it) and the coach grades your approach. Generating runnable code from your description is coming next.
Run or narrate your approach, then ask the coach.