Count Maximum Profitable Groups
Problem Overview
- Count the number of consecutive month groups where the first or last month equals the group's maximum.
- Input: stockPrice[n]; Output: long integer count; Constraints: 1 ≤ n ≤ 5e5, 1 ≤ stockPrice[i] ≤ 1e8.
- Real-world context: analyze Amazon stock prices over several months to find maximum profitable groups.
- From Amazon interviews; a coding interview problem and common interview question.
Example
Unlock to view complete problem details
and practice with sample input/output
Was this article helpful?
View Test Cases & Run Code requires membership
Input Variables
Execution Result:
