Problem · Hash Table

Members Lacking Provider Network Access

MediumOscar HealthFULLTIMEONSITE 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.

Examples
01 · Example 1
providers = [["1", "Cardiology", "1", "2"], ["2", "Dermatology", "3", "4"]]
members = [["101", "2", "3", "Cardiology|Dermatology"], ["102", "10", "10", "Cardiology"]]
maxDistance = 5
return = [102]

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

02 · Example 2
providers = [["1", "Cardiology", "0", "0"]]
members = [["1", "3", "4", "Cardiology"], ["2", "0", "0", "Dermatology"]]
maxDistance = 5
return = [2]

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

Constraints
  • 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.
drafts saved locally
public int[] findMembersLackingAccess(String[][] providers, String[][] members, int maxDistance) {
    // write your code here
}
providers[["1", "Cardiology", "1", "2"], ["2", "Dermatology", "3", "4"]]
members[["101", "2", "3", "Cardiology|Dermatology"], ["102", "10", "10", "Cardiology"]]
maxDistance5
expected[102]
checking account