FastPrepFastPrep
Problem Brief

Members Lacking Provider Network Access

FULLTIMEONSITE INTERVIEW

You are given a list of providers and a list of members.

Each provider row is encoded as [providerId, specialty, x, y]. Each member row is encoded as [memberId, x, y, requiredSpecialties], where requiredSpecialties is a pipe-delimited string such as "Cardiology|Dermatology".

A member lacks adequate provider network access if there exists at least one required specialty for which no provider of that specialty lies within maxDistance of the member.

Use Euclidean distance. Return the ids of all members who lack adequate access in ascending order.

Function Description

Complete the function findMembersLackingAccess in the editor below.

findMembersLackingAccess has the following parameters:

  1. String[][] providers: provider rows [providerId, specialty, x, y]
  2. String[][] members: member rows [memberId, x, y, requiredSpecialties]
  3. int maxDistance: the maximum allowed Euclidean distance

Returns

int[]: the ids of members lacking adequate access, sorted ascending.

1Example 1

Input
providers = [["1", "Cardiology", "1", "2"], ["2", "Dermatology", "3", "4"]], members = [["101", "2", "3", "Cardiology|Dermatology"], ["102", "10", "10", "Cardiology"]], maxDistance = 5
Output
[102]
Explanation

Member 101 has both required specialties within distance 5. Member 102 has no nearby cardiology provider.

2Example 2

Input
providers = [["1", "Cardiology", "0", "0"]], members = [["1", "3", "4", "Cardiology"], ["2", "0", "0", "Dermatology"]], maxDistance = 5
Output
[2]
Explanation

Member 1 is exactly distance 5 from the cardiology provider, so access is adequate. Member 2 requires dermatology, which is unavailable.

Constraints

Limits and guarantees your solution can rely on.

  • 1 <= providers.length, members.length <= 10^5
  • Coordinates are numeric values stored as strings in the encoded input.
  • A member is reported if any required specialty is missing within maxDistance.
  • The answer must be sorted ascending for deterministic output.
public int[] findMembersLackingAccess(String[][] providers, String[][] members, int maxDistance) {
    // write your code here
}
Input

providers

[["1", "Cardiology", "1", "2"], ["2", "Dermatology", "3", "4"]]

members

[["101", "2", "3", "Cardiology|Dermatology"], ["102", "10", "10", "Cardiology"]]

maxDistance

5

Output

[102]

Sign in to submit your solution.