Which boundary I miss in this code i am getting one less then actual answer in only one test case


#1

int max1=INT_MIN,min1=INT_MAX;
int a=0,b=0;
for(int i=0;i<A.size();i++){
if(max(A[i],max1)!=max1)
a=i;
max1=max(A[i],max1);
if(min(A[i],min1)!=min1||min1==A[i])
b=i;
min1=min(A[i],min1);
}
return abs(max1-min1)+abs(a-b);


#2

I got it.
There is one mistake thanks InterviewBit for the solution.