Dsa
Two Pointers
Easy
Temperature Trend Finder
You are given an array of integers representing daily temperatures. You need to determine the maximum number of consecutive days with a temperature trend (increase or decrease) without interruption. Write a program to find the length of this trend.
Input:
- A single line containing space-separated integers (1 ≤ |arr| ≤ 100000).
Output:
- An integer representing the maximum trend length.
Example:
Input:
30 32 31 33 34 32 31 30
Output:
5
Key concepts
two_pointersarraysmax_subarray
Practise this out loud — free
Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.
🎙 Practise this question now