What is the problem with this java code?

amazon
Tags: #<Tag:0x00007f24280ec218>

#1

import java.lang.Math.*;

public class Solution {
public int maxArr(ArrayList A) {
int max=0;
int n=A.size();
int sum=0;

    for(int i=0;i<n-1;i++){
        for(int j=0;j<n-1;j++) {
         
            if(i==j)
            {
                sum=0;
            }
            
            sum=Math.abs(A.get(i)-A.get(j)) + Math.abs (i-j);
            max=Math.max(sum,max);
        }
    }
    return max;

}

}


#2

Your 2nd loop should be this:
for(int j=1;j<n;j++)