Posted on

Description

Submission

class Solution {
public:
    int maxAbsoluteSum(vector<int>& nums) {
        int sum = 0;
        nums.insert(nums.begin(), 0);
        int maximum = - INT_MAX / 2;
        int minimum = INT_MAX / 2;
        for(auto x : nums) {
            sum += x;
            minimum = min(minimum, sum);
            maximum = max(maximum, sum);
        }
        return abs(minimum - maximum);
    }
};

Leave a Reply

Your email address will not be published. Required fields are marked *