DrawCode Practice Problem

Maximum Subarray

Given an integer array `nums`, find the contiguous subarray with the largest sum and return that sum.

Examples

Input

nums = [-2,1,-3,4,-1,2,1,-5,4]

Output

6

Subarray [4,-1,2,1] has sum 6.

Constraints


Interactive Visualizer Workspace

Explore step-by-step interactive animations, memory state tracking, and live multi-language execution in DrawCode.

Launch Interactive Visualizer