Katkat

Find Maximum Sum of Contiguous Subarray Length k

AppleData Scientist · Technical Screen

Last 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(

  1. space.