A budgeting app lists daily balance changes in spend (positive or negative). A streak is a run of back-to-back days.
Write budgetStreaks(spend, budget) that returns how many streaks have changes adding up to exactly budget. Streaks that cover different days count separately, even if they overlap.
Input: spend = [2,3,-1,4,1], budget = 5 Output: 2
[2, 3] and [4, 1] add up to 5.
Input: spend = [1,1,1], budget = 2 Output: 2
Days 0 and 1, and days 1 and 2, each add to 2.
0 <= spend.length <= 10^5-1000 <= spend[i] <= 1000-10^7 <= budget <= 10^7Run tries your code on the examples. Submit runs every test, including hidden edge cases and big inputs that check your code is fast enough, and solves the problem when they all pass.
Ctrl + Enter runs, Ctrl + Shift + Enter submits (⌘ on a Mac).
I'm here to help with #45 Spending Streaks on Budget. 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.