Python interview question: maximum average subarray of at least k

HardBinary search

Problem

orders[i] is the number of orders in hour i. For a press release, return the highest average number of orders per hour over any run of at least k consecutive hours.

def best_period_average(orders: list[int], k: int) -> float:

Example

Solve it free

Checked against hidden tests, right in your browser. No sign-up needed.

Skills it tests

More interview questions

All questions