Find Maximum Sum of Contiguous Subarray Length k
AppleData Scientist · Technical ScreenLast updated
This question evaluates skill in array manipulation and computing aggregate metrics over fixed-length intervals, along with understanding of algorithmic complexity and trade-offs between runtime and memory.
Scenario
Monitoring website traffic and needing the highest traffic within any fixed-length time window.
Question
Given an array of positive integers representing hits per minute and an integer k, return the maximum sum of any contiguous subarray of length k. Provide time and space complexity.
Hints
Two-pointer sliding window keeps running sum; O(n) time, O(
- space.
Solution walkthrough is for members
Get the full walkthrough with reference code and complexity analysis, plus Kitty Coach at 300 messages a day. Hints, the code runner and community answers stay free.