Find Ideal Days
Problem Overview
- Task: Given rainfall array day and integer k, find all indices i where the prior k days are non-increasing and the following k days are non-decreasing.
- Input/Output: Input is day and k; return the ideal days in ascending order (days correspond to 1-based dates).
- Context: Alexa feature to suggest camping days from weather forecasts.
- Constraints: 1 ≤ k ≤ n ≤ 2e5, 0 ≤ day[i] ≤ 1e9; at least one ideal day exists.
- Source: Amazon interviews; a coding interview problem and 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:
