Python 3 O(n) solution


#1
class Solution:
    def coverPoints(self, A, B):
        x1 = A[0]
        y1 = B[0]
        res = 0
        for i in range(1,len(A)):
            x2,y2 = A[i],B[i]
            diff1 = abs(x1-x2)
            diff2 = abs(y1-y2)
            res += diff1 + diff2
            if x1!=x2 and y1!=y2:
                res-=min(diff1,diff2)
            x1,y1 = x2,y2
        return res