This problem can be solved use several different algorithmic techniques, including brute force, divide and conquer, dynamic programming, and reduction to shortest paths. If the array contains all non-positive numbers, then a solution is any subarray of size 1 containing the maximal value of the array (or the empty subarray, if it is allowed). The maximal subarray problem was proposed by Ulf Grenander in 1977 as a simplified model for maximal likelihood estimate of shapes in digitized pictures. There is some evidence that no significantly faster algorithm exists; an algorithm that solves the two-dimensional maximal subarray problem in O(n3−ε) time, for any ε>0, would imply a similarly fast algorithm for the all-pairs shortest paths problem. Grenander derived an algorithm that solves the one-dimensional problem in O(n2) time, better the brute force working time of O(n3).

COMING SOON!

```
function KadaneAlgo (array) {
let cummulativeSum = 0
let maxSum = 0
for (var i = 0; i < array.length; i++) {
cummulativeSum = cummulativeSum + array[i]
if (cummulativeSum < 0) {
cummulativeSum = 0
}
if (maxSum < cummulativeSum) {
maxSum = cummulativeSum
}
}
return maxSum
// This function returns largest sum contigous sum in a array
}
function main () {
var myArray = [1, 2, 3, 4, -6]
var result = KadaneAlgo(myArray)
console.log(result)
}
main()
```