Problem bank
Problem 240 of 333MediumCodingP240
Stock span
Given a list of daily closing prices, the span on day is the number of consecutive days ending at day (including day itself) whose close is at most the close on day . For prices 100, 80, 60, 70, 60, 75, 85 the spans are 1, 1, 1, 2, 1, 4, 6. Compute every span in time.
Check your answer and see the solution with a free account
Every problem on Quant Engine is free, with a hint and a full worked solution. Making an account takes 30 seconds and no card. Then you can write and check your answers, see the solutions, and track what you have solved.