Skip to the code
cf.
+10 XP

#495 Strongest Run of Daily Signups

easy

An analytics dashboard stores deltas[i], the change in daily signups on day i compared with the day before. It can be negative.

Write strongestRun(deltas) that returns the largest sum of a run of one or more consecutive days.

Example 1

Input: deltas = [-3,2,-4,5,-1,3,1,-6,4]
Output: 8

Days 3 to 6: 5 - 1 + 3 + 1 = 8.

Example 2

Input: deltas = [-3,-1,-2]
Output: -1

Every day is negative, so the best run is the single day with -1.

Constraints

  • 1 <= deltas.length <= 100000
  • -10000 <= deltas[i] <= 10000
Saved in this browser

Run 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).