How to find two most distant points?

后端 未结 9 1978
旧巷少年郎
旧巷少年郎 2020-11-29 19:05

This is a question that I was asked on a job interview some time ago. And I still can\'t figure out sensible answer.

Question is:

you are given set of points

9条回答
  •  一生所求
    2020-11-29 19:42

    This seems easy if the points are given in Cartesian coordinates. So easy that I'm pretty sure that I'm overlooking something. Feel free to point out what I'm missing!

    1. Find the points with the max and min values of their x, y, and z coordinates (6 points total). These should be the most "remote" of all the boundary points.
    2. Compute all the distances (30 unique distances)
    3. Find the max distance
    4. The two points that correspond to this max distance are the ones you're looking for.

提交回复
热议问题