1

Euclidean Distance

Unsolved
Fundamentals

Difficulty: 1 | Problem written by Mr. Umair

Educational Resource: https://hlab.stanford.edu/brian/euclidean_distance_in.html


Problem reported in interviews at

Amazon
Netflix

The Euclidean distance between two points in Euclidean space is the length of a line segment between the two points. It can be derived from the Cartesian coordinates of the points using the Pythagorean theorem.

\(d(x,y) = \sqrt{(x_2-x_1)^2 + (y_2-y_1)^2}\)

 

Input:

Two NumPy arrays will be given as input for calculating distance between them using Euclidean Distance.

Output:

Distance between two input arrays.

Sample Input:
<class 'list'>
arr1: [1 2 3]
arr2: [4 5 6]

Expected Output:
<class 'float'>
5.196152422706632

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

Ipsa expedita explicabo aspernatur voluptas, sint tempora in ad est corporis ipsam ab labore architecto obcaecati iste. Temporibus tempora ullam excepturi odio maiores eligendi velit pariatur dignissimos hic. Ratione neque doloribus quas quam voluptas reiciendis laboriosam exercitationem eveniet inventore amet, inventore ex veniam tempora deserunt consequatur mollitia nobis, dicta harum itaque fuga, quidem deleniti necessitatibus magni odio quis aliquam voluptate aliquid, ab repudiandae iure soluta itaque rerum sequi velit? Rem dolorum minus facere ducimus placeat cupiditate suscipit ea.

Architecto quaerat quia animi perspiciatis officiis ipsum illo?

Sunt rem illum deleniti amet quo quisquam reprehenderit atque sit, at deleniti vitae ducimus voluptatem placeat fugiat tempore dicta fuga, sint modi quo iste inventore delectus repellendus natus fugit ab nisi ipsum, aut nemo asperiores magni repellendus minima qui eveniet ducimus iusto, tempora praesentium itaque repudiandae accusantium illum ad provident.

This is a premium feature.
To access this and other such features, click on upgrade below.

Ready.

Input Test Case

Please enter only one test case at a time
numpy has been already imported as np (import numpy as np)