Euclidean and Manhattan distance
Given two equal-length numeric vectors, return both their Euclidean (L2) distance and their Manhattan (L1) distance as a two-element list [euclidean, manhattan]. Euclidean distance is the square root of the sum of squared differences; Manhattan distance is the sum of absolute differences. Inputs are non-empty lists of the same length. Round each distance to 4 decimal places.
Implement
distances(a: list[float], b: list[float]) → list[float]Examples
in
[[0,0],[3,4]]out[5,7]What a strong answer looks like
State your approach and its time/space complexity out loud before you optimize. Handle the edge cases (empty input, duplicates, overflow), and say why you chose this over the brute force. Green tests are the floor, not the grade.
0:00 of about 12 min
solution.py
InputExpectedGot
[[0,0],[3,4]][5,7]not run yetsample