Quick Overview

This question evaluates array manipulation, algorithmic efficiency, and familiarity with the sliding-window technique for computing metrics over fixed-length contiguous subarrays.

Find Maximum Window Sum

Company: DoorDash

Role: Analytics Engineer

Category: Coding & Algorithms

Difficulty: hard

Interview Round: Technical Screen

Given an integer array nums and an integer k, write code to find the maximum sum of any contiguous subarray of length exactly k. Assume 1 <= k <= len(nums), values may be negative, and the expected solution should run in O(n) time using a sliding-window approach.

Quick Answer: This question evaluates array manipulation, algorithmic efficiency, and familiarity with the sliding-window technique for computing metrics over fixed-length contiguous subarrays.

Return the maximum sum of any contiguous subarray of length exactly k.

Constraints

  • Inputs are provided as Python literals matching the function signature.
  • Return a deterministic exact-match result.

Examples

Input: ([1,2,3,4,5], 2)

Expected Output: 9

Explanation: Best length-two window.

Input: ([-5,-2,-3], 2)

Expected Output: -5

Explanation: All negative.

Hints

  1. Choose a representation that makes the core operation simple.
  2. Handle empty and boundary inputs before the main algorithm.

Loading coding console...