A growth dashboard lists net follower changes per day in gains (they can be negative). It highlights the best streak: the run of back-to-back days (at least one) with the largest total.
Write bestStreak(gains) that returns that largest total.
Input: gains = [2,-5,3,-1,4,-6,2] Output: 6
Days 2 to 4 give 3 - 1 + 4 = 6.
Input: gains = [-4,-2,-7] Output: -2
Every day is a loss, so the best streak is the single least bad day.
1 <= gains.length <= 10^5-10^4 <= gains[i] <= 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 #60 Best Streak of Daily Gains. 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.