Given an array of daily temperature fluctuations, find the minimum length of a subarray that contains alternating increases and decreases in temperature.
Explanation: Step-by-step: Given the array [20, 15, 30, 25, 10], we can see that the subarray [20, 15, 30, 25, 10] has alternating increases and decreases in temperature. The minimum length of this subarray is 5.
Explanation: Step-by-step: Given the array [10, 20, 15, 30, 25, 10, 35], we can see that the subarray [10, 20, 15, 30, 25, 10, 35] has alternating increases and decreases in temperature. The minimum length of this subarray is 7.
Master coding challenges related to Arrays and solve the [Backup] Temperature Fluctuation Analysis problem optimally.
No dry run loaded.
🚀 Practice this problem
Run code, get AI hints & track streak