Блог пользователя Abhizen

Автор Abhizen, история, 6 лет назад, По-английски

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.

  1. 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
  2. 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
  • Проголосовать: нравится
  • 0
  • Проголосовать: не нравится

»
6 лет назад, # |
Rev. 2   Проголосовать: нравится +3 Проголосовать: не нравится
1 4
2 4 6 7 12
1 1 0 1 1

Try this test for first solution