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  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

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

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