Longest run of trades within a cost budget
You have a stream of non-negative trade costs and a spending budget B. Find the maximum number of consecutive trades whose total cost stays within B.
costs = [1, 2, 1, 4, 1], B = 4
-> 3 # the run [1, 2, 1] costs 4
Return the length of the longest contiguous run with total cost at most B. Aim for .
Your answer
This one is open-ended. Work it through, then check your reasoning against the full solution.