Short and simple O(n) cpp solution


#1

int Solution::coverPoints(vector &A, vector &B) {
int dx,dy=0;
int count=0;

for(int i=0;i<A.size()-1;i++){
    dx=abs(A[i+1]-A[i]);
    dy=abs(B[i+1]-B[i]);
    count+=max(dx,dy);
    
    
}

return count;

}