Output Explaination

In the first case, can anyone explain how 200 is the answer?

add 10,10=200
add 9,9=162
add 8,8=128

give 3rd nearest dist = 200

Rocket distance between two points ( x2 , y2 ) and ( x1 , y1 ) is defined as (x2 - x1)2 + (y2 - y1)2.
Dean is always at (0,0) and one query point is (10,10).
So distance as per the equation is (10-0)2+(10-0)2 = 20 + 20 =40.
How come its 200?

its power with 2. Not multiply with 2.
This is something very basic and understood. You should have understood it at once by looking at the test case.

  1. In the question, the equation is not properly written.
  2. If you had explained properly in the first reply, it would not have been the issue.
    Thanks for reply.

Never mind, didn’t know you will get it the other way. Though i won’t deny your first point:+1:
Happy Coding
You may close the doubt if resolved now :slight_smile: