Let’s say I have an array with CGPoints (wrapped with NSValues). How can I get the two points which are most distant from each other. I mean the distance between these two points is the biggest? I can just check every two points but that does not look efficient. Is there a better way of doing this?
Thanks for help!
If there are not too many points (up to 1000, but if intensive, around 100), use the naive brute-force method O(n2).
I haven’t read the details, but the biggest distance probably is computable in O(nlog n) with convex hull algorithm + rotating caliper.