题解 | #矩阵中的路径#
连续子数组的最大和
http://www.nowcoder.com/practice/459bd355da1549fa8a49e350bf3df484
class Solution {
public:
int FindGreatestSumOfSubArray(vector<int> array) {
vector<int> dp;
dp.push_back(array[0]);
int ans = dp[0];
for(int i=1; i<array.size(); i++){
dp.push_back(max(array[i],array[i]+dp[i-1]));
ans = max(ans,dp[i]);
}
return ans;
}
};