My simple O(n) solution


#1

int Solution::coverPoints(vector &A, vector &B) {
int x=0,y=0,dis=0,dissum=0;
for(int i=0;i<A.size()-1;i++){
x=A[i+1]-A[i];
y=B[i+1]-B[i];
x=abs(x);
y=abs(y);
dis=max(x,y);
dissum+=dis;
}
return dissum;
}