**Question: Write a program to find the sum of contiguous subarray within a one-dimensional array of numbers which has the largest sum.**

**Answer:**

We need to focus on the fact that whenever sum of digits of array goes less than zero it is better to keep the sum as 0. Anywhere we’ll encounter a positive integer we’ll again start the sum.

Example:

array : -2 -3 4 -1 -2 1 5 -3

sum : 0 0 4 3 1 2 7 4

So 7 is the result.

**Code:**