Shortest run of trades reaching a target cost
Asked at Jump Trading, SIG
You have a stream of non-negative trade costs and a target T. Find the length of the shortest contiguous run of trades whose total cost is at least T. If no run reaches T, return 0.
costs = [2, 3, 1, 2, 4, 3], T = 7
-> 2 # the run [4, 3] already hits 7
Return the minimum length of a contiguous run summing to at least T. Aim for .
Your answer
This one is open-ended. Work it through, then check your reasoning against the full solution.