Best K-Day Sales Window
sales[i] is the net sales on day i (it can be negative after refunds). Return the largest total over any k consecutive days.
Example 1
Input: sales = [1, 12, -5, -6, 50, 3], k = 4 Output: 51 Explanation: Days 1..4 give 12 - 5 - 6 + 50 = 51.
Example 2
Input: sales = [5], k = 1 Output: 5
Constraints
- 1 <= k <= sales.length <= 10^5
- -10^4 <= sales[i] <= 10^4
Hint 1
Compute the first window, then slide: add the new day and drop the oldest one.
Good practice for: Data Scientist, Data Engineer, Machine Learning Engineer, AI Engineer (LLM & Generative AI), Backend Developer, Full Stack Developer
Run checks your code on 2 sample tests. Submit runs all 7 tests, including hidden ones, and earns points. Use console.log to debug. Python's first run can take a few seconds while it starts.