Perfect working cpp code


#1

int Solution::maxArr(vector &A) {
int highhigh=INT_MIN,lowlow=INT_MAX,highlow=INT_MIN,lowhigh=INT_MAX;
for(int i=0;i<A.size();i++){
highhigh=max(highhigh,A[i]+i);
lowlow=min(lowlow,A[i]+i);
highlow=max(highlow,A[i]-i);
lowhigh=min(lowhigh,A[i]-i);
}
int ans=INT_MIN;
ans=max(ans,abs(highhigh-lowlow);
ans=max(ans,abs(highlow-lowhigh));
return ans;
}