if (nums.Length == 0)

return 0;

int maxValue = nums[0];

int curr = 0;

for(int i=0;i<nums.Length;i++)

{

curr += nums[i];

```
if (maxValue < curr)
maxValue = curr;
if (curr < 0)
curr = 0;
}
return maxValue;
```