I have solved this problem Taxi drivers and Lyft using two approaches. My first solution does not pass test case 5 where as second solution passes all test cases. Test case 5 is pretty big to figure out the mistake. Please help me figure out what is the problem with my first approach.
- By iterating over people array and storing distance of next taxi driver in a separate array. Then I am iterating again on people array to count riders for each taxi based on distance between taxi driver and rider. First solution
- By iterating over people array and storing taxi driver coordinate and rider coordinate in separate array. Then I am iterating over rider coordinate array and iterate over taxi driver coordinate array in nested loop based on distance between rider and taxi driver. Second solution