0

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 'numpy.ndarray'>
arr1: [1 2 3]
<class 'numpy.ndarray'>
arr2: [4 5 6]

Expected Output:
<class 'float'>
5.196152422706632

This is a premium problem, to view more details of this problem please sign up for MLPro Premium. MLPro premium offers access to actual machine learning and data science interview questions and coding challenges commonly asked at tech companies all over the world

MLPro Premium also allows you to access all our high quality MCQs which are not available on the free tier.

Not able to solve a problem? MLPro premium brings you access to solutions for all problems available on MLPro

Get access to Premium only exclusive educational content available to only Premium users.

Have an issue, the MLPro support team is available 24X7 to Premium users.

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

Log in to post a comment

Comments
Ready.

Input Test Case

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