Algorithm · Databricks · Medium
You are given an integer array in which each value is the revenue earned on one day. Determine the contiguous range of days with the largest total revenue, and return that total. Your algorithm must run in O(n) time. Example 1: Input: [80, 140, 110, 0, 190] Output: 520 Example 2: Input: [-4, -2, -7, 0] Output: 0 Constraints: The array length is between 0 and 10^5, inclusive. A revenue value may be negative, representing a loss. Example
Checking your access…