A partnership report splits a year of monthly revenue revenue (all values 0 or more) into three non-empty back-to-back periods: an early part, a middle part, and a late part.
A split is fair if sum(early) <= sum(middle) <= sum(late). Write fairSplits(revenue) that returns how many fair splits exist. Two splits are different if either cut is in a different place.
Input: revenue = [1,1,1] Output: 1
The only split is [1] [1] [1], and 1 <= 1 <= 1.
Input: revenue = [1,2,3,4] Output: 2
[1] [2] [3, 4] and [1, 2] [3] [4] are fair; [1] [2, 3] [4] is not, since 5 > 4.
3 <= revenue.length <= 10^50 <= revenue[i] <= 10^4Run 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 #44 Three-Way Revenue Split. 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.