Investable Periods

Asked at MathWorks · Coding & Leetcode-style Questions · Difficulty: Medium

A trading firm predicts the stock prices of a commodity for the next `n` days. A period of consecutive days is considered investable if the maximum price in the period is `max_price`, and the minimum price in the period is `min_price`. Find the number of investable periods in the next `n` days.

Loading the problem…