A shop dashboard marks a stretch of k days in a row as steady when the average daily sales over those days is at least threshold.
Write countSteady(sales, k, threshold) that returns how many stretches of exactly k consecutive days are steady. Stretches may overlap.
Input: sales = [2,2,2,2,5,5,5,8], k = 3, threshold = 4 Output: 3
The stretches [2, 5, 5], [5, 5, 5], and [5, 5, 8] average 4, 5, and 6.
Input: sales = [1,1,1], k = 1, threshold = 2 Output: 0
No single day reaches 2.
1 <= k <= sales.length <= 1000000 <= sales[i], threshold <= 10^4Run tries your code on the examples. Submit runs every test, including hidden edge cases, and solves the problem when they all pass.
Ctrl + Enter runs, Ctrl + Shift + Enter submits (⌘ on a Mac).
I'm here to help with #126 Count Steady Sales Weeks. I give hints, never the solution, so you get to solve it yourself. Ask for a hint, select code to ask about it, or press Ask Tuto why on a failing test.
Your first 3 answers need no account. for free to keep asking.