Description
7. Apartment Hunting

You're moving to a new city and looking for an apartment to live in. There are several amenities you need access to from your new place: a grocery store, a school, and a gym, among others. Given a list of amenities and a map of the city where each block is marked with the amenities available on that block, write a function to find the block that minimizes the farthest distance to all your required amenities.

Example 1

Input:  [[["grocery", "school"], ["school", "gym"], ["grocery"], ["gym", "school"]], ["grocery", "school", "gym"]]
Output: 2

Example 2

Input:  [[["gym"], ["school", "gym"], ["grocery", "school"]], ["grocery", "school", "gym"]]
Output: 1
Constraints:
    • 1 <= blocks.length <= 10^4
    • Each block can have any combination of the given amenities.
    • The list of requirements is non-empty and contains no duplicates.
Test Cases

Case 1
Case 2

Input

[[["grocery", "school"], ["school", "gym"], ["grocery"], ["gym", "school"]], ["grocery", "school", "gym"]]

Output

2