← 返回 databricks 的题目列表Revenue Calculation
类型:online_judge
databricks
Given an integer array, each element in the array represents the revenue of a certain day. You need to find the consecutive days where the sum of these days' revenues is the maximum. Output the maximum revenue sum. The solution should have a time complexity of O(n).
Example 1: Input: [100, 200, 150, 0, 250] Output: 450
Example 2: Input: [-1, -2, -3, 0] Output: 0
Constraints:
The length of the array ranges from [0, 10^5]
Revenue can be negative, indicating a loss
Example
Input
[100, 200, 150, 0, 250]