Manhattan Distance
EasyMachine LearningMath
Description
Given two equal-length points a and b, return the Manhattan (L1) distance, the sum of absolute coordinate differences.
Examples
Input:
a = [0,0], b = [3,4]Output:
7Explanation:
Summing the absolute coordinate differences gives 7.
Input:
a = [1,1], b = [1,1]Output:
0Explanation:
Summing the absolute coordinate differences gives 0.
Input:
a = [1,2,3], b = [4,6,8]Output:
12Explanation:
Summing the absolute coordinate differences gives 12.
Constraints
- •
1 ≤ a.length ≤ 10⁴