rendered paste bodypublic static void main(String[] args) {
// TODO code application logic here
int[] intArr = {-2, 11, -4, 13, -5, 2};
int maxSum = 0, maxStart = 0, maxEnd = 0, tempSum = 0;
for(int x = 0; x < intArr.length; x++) {
for(int y = x; y < intArr.length; y++) {
for(int z = x; z <= y; z++) {
tempSum += intArr[z];
}
if(tempSum > maxSum) {
maxSum = tempSum;
maxStart = x;
maxEnd = y;
}
tempSum = 0;
}
}
System.out.println("maxSum : " + maxSum);
System.out.println("maxStart : " + maxStart);
System.out.println("maxEnd : " + maxEnd);
}