Codility - MaxSliceSum

RESULT

import java.util.*;

class Solution {
    public int solution(int[] A) {
        int maxSlice = A[0];
        int maxSliceSum = A[0];
        for (int i=1; i<A.length; i++) {
            maxSlice = Math.max(A[i], maxSlice + A[i]);
            maxSliceSum = Math.max(maxSliceSum, maxSlice);
        }
        
        return maxSliceSum;       
    }
}