function FindGreatestSumOfSubArray(array)
{
let maxCount = Math.min.apply(null, array); //因为有可能都是负数,所以初始化给最小值
for (let i=0; i<array.length; i++) {
let total = 0;
for (let j=i+1; j<=array.length; j++) {
total = array.slice(i, j).reduce((pre, data) => {
return pre + data;
});
if (total > maxCount) {
maxCount = total;
}
}
}
return maxCount;
}
module.exports = {
FindGreatestSumOfSubArray : FindGreatestSumOfSubArray
};