Description
5. Find Nearest Store

You're developing a feature for a mapping application where users can find the nearest store to their current location. Given a list of store locations (as coordinates) and a user's current location, write a function to find the store nearest to the user.

The function should take two parameters:

  • A list of store locations, where each store location is represented as a tuple of (x, y) coordinates.
  • The user's current location, also represented as a tuple of (x, y) coordinates.

The function should return the (x, y) coordinates of the store that is closest to the user's current location. If there are multiple stores at the same minimum distance, the function can return any one of them.

Example 1

Input:  [[1, 2], [3, 4], [2, -1]], [0, 0]
Output: [1, 2]

Example 2

Input:  [[0, 0], [5, 5], [2, 2]], [3, 3]
Output: [2, 2]
Constraints:
  • 1 <= stores.length <= 10^4
  • The coordinates are integers where -10^4 <= x, y <= 10^4.
  • No two stores are at the same location.
  • The user's location is not necessarily the same as any store's location.
Test Cases

Case 1
Case 2

Input

[[1, 2], [3, 4], [2, -1]], [0, 0]

Output

[1, 2]