Solving Quora's Nearby problem