Loading Question...
Given two points (x1, y1) and (x2, y2), calculate the distance of each point from the origin (0, 0).
Round each distance to the nearest integer and return the rounded distances.
The distance of a point (x, y) from the origin is:
distance = √(x² + y²)
Input:
P1 = (3, 4)
P2 = (6, 8)
Distance of P1:
√(3² + 4²)
= √25
= 5
Distance of P2:
√(6² + 8²)
= √100
= 10
Output:
5 10
Input:
P1 = (2, 3)
P2 = (5, 7)
P1 distance = √13 ≈ 3.606 → 4
P2 distance = √74 ≈ 8.602 → 9
Output:
4 9
-10^9 ≤ x1, y1, x2, y2 ≤ 10^9
Expert in Data Structures & Algorithms. Building tools to help developers crack FAANG interviews.
Schlumbergera • Pending
Schlumbergera • Pending
Willingness • Pending
Willingness • Pending
Willingness • Pending