Distance between 2 points
School Accuracy: 34.54% Submissions: 55 Points: 0

Given coordinates of 2 points on a cartesian plane, find the distance between them rounded up to nearest integer.

Example 1:

Input: 0 0 2 -2
Output: 3
Explanation: Distance between (0, 0) 
and (2, -2) is 3.

Example 2:

Input: -20 23 -15 68
Output: 45
Explanation: Distance between (-20, 23) 
and (-15, 68) is 45.

Your Task:
You don't need to read or print anything. Your task is to complete the function distance() which takes x1, y1, x2 and y2 as input parameter and returns the distance between the given two points.

Expected Time Complexity: O(1)
Expected Space Complexity: O(1)

-1000 <= x1, y1, x2, y2 <= 1000

to report an issue on this page.


We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?


All Submissions

My Submissions:

Login to access your submissions.