Given a set of floating type points, find if there exist any pair of points that distance is <= sqrt(2).
One solution is to partition the grid into multiple unit 1 sqaure:
Maintain a hashMap[id] = {a list of points} where id is identification of unit square on grid ( ex : m rows and n cols can be used as i * n + j)
For this solution , I thought the worst case run time is still O(n^2) , for example like below case:
in this case, for each point we still end up check all the rest of point with it
|..|..|
--------
|..|..|Not sure if anyone know a way for O(N) solution?