class Solution { public: int FindGreatestSumOfSubArray(vector<int> array) { int n = array.size(); //vector<vector<int>> dp(n,vector<int>(n)); int currSum = 0, maxSum = INT_MIN, miniSum = 0; for(int i = 0; i < n; i++) { currSum += array[i]; maxSum = max(maxSum, currSum - miniSum); miniSum = min(miniSum, currSum); } return maxSum; } };