On a Meta Reels analytics stream, each integer in nums represents the gain or loss in engagement for a consecutive time window. Find the contiguous subarray with the largest possible sum and return that sum.
numsnumsYou must solve this in linear time.
Example 1
nums = [-2, 1, -3, 4, -1, 2, 1, -5, 4]6[4, -1, 2, 1] has sum 6, which is the largest possible.Example 2
nums = [1]1[1].Example 3
nums = [5, 4, -1, 7, 8]235 + 4 - 1 + 7 + 8 = 23.1 <= len(nums) <= 10^5-10^4 <= nums[i] <= 10^4nums contains at least one element