Bird
Raised Fist0

You have a list of API response times in milliseconds: times = [120, 100, 130, 90, 110, 150]. Using a sliding window of size 3, how would you find the maximum average response time for any window?

hard🚀 Application Q8 of Q15
Rest API - Rate Limiting and Throttling
You have a list of API response times in milliseconds: times = [120, 100, 130, 90, 110, 150]. Using a sliding window of size 3, how would you find the maximum average response time for any window?
ACalculate the average of each window and track the maximum average
BSum all response times and divide by total number of elements
CFind the maximum single response time in the list
DSort the list and pick the last three elements
Step-by-Step Solution
Solution:
  1. Step 1: Understand the problem requirement

    We need the maximum average of any consecutive 3 response times (sliding window size 3).
  2. Step 2: Calculate average for each window and track max

    Calculate sum of each window of size 3, divide by 3, and keep the highest average.
  3. Final Answer:

    Calculate the average of each window and track the maximum average -> Option A
  4. Quick Check:

    Max average = max of window averages [OK]
Quick Trick: Average each window, track max average [OK]
Common Mistakes:
MISTAKES
  • Calculating average of entire list instead of windows
  • Picking max single value instead of average

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Rest API Quizzes