C++17 5 line sol using STL algos


#1
#include <numeric>
int Solution::maxSubArray(const vector<int> &A) {
    vector<int> V(A.size(), 0);
    partial_sum(cbegin(A), cend(A), begin(V),
    [](auto a, auto b){ return b > a + b ? b : a + b; });
    return *max_element(cbegin(V), cend(V));
}