I recently appeared for my phone screening round and got this question:
For a stream of floating points, return any 3 points which have the distance between them less than a given value. Also, remove the 3 points from memory. There can be negative points as well and the distance has to be calculated between any two points.
Does anyone have a solution for this?
Example given was: 1.0,2.0,8.0,12.0,3.0
d = 3
When we encounter 3.0, the function should return 1.0,2.0,3.0 and it should be removed from memory as well