Skip to content
LakeBench
ProblemsCommunityPricing
Sign inStart practicing

Best 3-day sales window

Python data engineering interview problem. Difficulty: intermediate. Pattern: Sliding Window. About 15 minutes. Part of the Pro drill bank.

A store reports daily sales. Planning wants the 3-day window with the highest total so they can staff the peak.

Find the window of length k with the largest sum of sales.

Requirements

  • Windows are contiguous.
  • If the list is shorter than k, follow the tests (None vs 0).

Constraints

  • sales: daily amounts.
  • k: window length.
  • k is positive.
  • Sales may include zeros.

Examples

Input: best_window_sum([1, 4, 2, 10], 2) Output: 12 This input follows the stated rules and produces this output.

Topics: lakebench, python, sliding-window.

More Python interview questions · All interview problems · Learn data engineering

intermediate

Best 3-day sales window

Interview-style drill: Given daily sales figures, find the 3-day consecutive window with the highest total.

Find the window of length k with the largest sum of sales.