Sliding Window on Arrays
📖 Scenario: Imagine you are analyzing daily temperatures over a week. You want to find the highest temperature recorded in every 3-day period to understand short-term heat waves.
🎯 Goal: Build a program that uses the sliding window technique to find the maximum temperature in every 3-day window from a list of daily temperatures.
📋 What You'll Learn
Create an array called
temperatures with exactly these values: 30, 32, 31, 35, 33, 34, 36Create an integer variable called
window_size and set it to 3Use a
for loop with variable i to slide the window over the array and find the maximum temperature in each windowPrint the maximum temperatures for each 3-day window separated by spaces
💡 Why This Matters
🌍 Real World
Sliding window technique is used in weather data analysis, stock price monitoring, and network traffic analysis to find trends over fixed-size periods.
💼 Career
Understanding sliding window helps in roles like data analysis, software development, and system monitoring where processing continuous data streams efficiently is important.
Progress0 / 4 steps
