Find Maximum Sum of Contiguous Subarray Length k
Company: Apple
Role: Data Scientist
Category: Coding & Algorithms
Difficulty: medium
Interview Round: Technical Screen
Overview: 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.
Constraints
- 1 <= n <= 200000 where n = len(nums)
- 1 <= k <= n
- 1 <= nums[i] <= 1000000000
- Result fits in 64-bit signed integer
Hints
- Compute the sum of the first k elements as the initial window.
- Slide the window by adding the next element and subtracting the element that leaves; track the maximum sum.