Nondecreasing Growth Streak
Preview mode. Log in to edit, run, submit, and save progress.
Nondecreasing Growth Streak
A daily growth metric is considered calm while each reading is at least as large as the previous reading. For every metric log, find the longest calm streak that uses consecutive readings from the original order. Input Format: The first line contains t, the number of test cases. Each test case contains n followed by n readings. Output Format: For each test case, print the length of the longest non-decreasing contiguous streak.
Examples
1 6 2 2 1 3 4 1
3
Explanation: The streak 1, 3, 4 is consecutive and non-decreasing, so it has length 3.
Approach hint
Start with the simplest clear approach, explain the trade-off, then move toward the cleaner answer.
Common mistake
Skipping assumptions, edge cases, or trade-offs can make an otherwise good answer feel incomplete.