Most visited location

tuples

Most visited location

DoorDash Python Interview Question

DoorDash records each dasher stop as a pair of grid coordinates [x, y]. The logistics team wants the location visited most often.

Write a function most_visited(stops) that returns the most visited location as a pair of coordinates. If several locations tie, return the one that was visited first.

Asked of

  • Data Analyst
  • Data Engineer
  • Data Scientist
  • ML Engineer
  • AI Engineer

Example 1

Input

stops = [[1, 1], [2, 3], [4, 0], [2, 3]]

Output

[2, 3]

Example 2

Input

stops = [[0, 0], [5, 5], [5, 5], [0, 0]]

Output

[0, 0]

Explanation

In the first example, the location [2, 3] is visited twice and every other location once, so the answer is [2, 3]. In the second example, [0, 0] and [5, 5] are both visited twice, and [0, 0] appears first.

Submit also runs 3 hidden test cases that check edge cases.