Maximum non-consecutive stall scores
You are driving a long highway with food stalls in a fixed order, and a review app shows each stall's taste score (a positive integer). If you stop at a stall you will be too full to stop at the very next one, so you can never visit two consecutive stalls. Given the list of scores in road order, return the maximum total taste score you can collect over the whole trip. An empty list returns 0.
Implement
max_stall_score(scores: list[int]) → intExamples
in
[[4,9,6,3,8]]out18in
[[2,7,9,3,1]]out12What 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
[[4,9,6,3,8]]18not run yetsample[[2,7,9,3,1]]12not run yetsample