Solve Morse and Network Access Tasks
Problem 1: Convert Between Text and Morse Code
You are provided with the standard Morse-code mapping for lowercase English letters:
- a: .-
- b: -...
- c: -.-.
- d: -..
- e: .
- f: ..-.
- g: --.
- h: ....
- i: ..
- j: .---
- k: -.-
- l: .-..
- m: --
- n: -.
- o: ---
- p: .--.
- q: --.-
- r: .-.
- s: ...
- t: -
- u: ..-
- v: ...-
- w: .--
- x: -..-
- y: -.--
- z: --..
Given a string consisting only of lowercase English letters, return its concatenated Morse-code representation.
Example:
Input: "gin"
Output: "--...-."
Follow-up: Given a Morse-code string with no separators between letters, generate all possible original lowercase strings that could have produced it.
Problem 2: Find Members Without Adequate Provider Access
You are given the following data:
- A list of
providers, where each provider has anid,specialty, and a 2Dlocation(e.g.,(x, y)). - A list of
members, where each member has anid, a 2Dlocation, and a list ofrequired_specialties. - A
max_distancevalue.
A member is considered to have adequate network access if, for every specialty they require, there is at least one provider of that specialty within max_distance of the member. The distance between locations should be calculated using Euclidean distance.
Your task is to return a list of member IDs who do not have adequate network access.
Example:
providers = [
{"id": 1, "specialty": "Cardiology", "location": (1, 2)},
{"id": 2, "specialty": "Dermatology", "location": (3, 4)}
]
members = [
{"id": 101, "location": (2, 3), "required_specialties": ["Cardiology", "Dermatology"]},
{"id": 102, "location": (10, 10), "required_specialties": ["Cardiology"]}
]
max_distance = 5
Output:
[102]
AI interview prep
Core dilemma
The core dilemma is demonstrating proficiency across two distinct problem types (string algorithms/backtracking and spatial data processing/optimization) within a single interview. For Problem 2, it's balancing correctness with efficiency when dealing with potentially large-scale geographic data and complex filtering criteria.
3 tradeoffs and 3 stress tests locked
Interview prep
Unlock the interviewer X-Ray rubric, tradeoff matrix, stress tests, clarifying questions, and key concepts.
Solve Morse and Network Access Tasks
Problem 1: Convert Between Text and Morse Code
You are provided with the standard Morse-code mapping for lowercase English letters:
- a: .-
- b: -...
- c: -.-.
- d: -..
- e: .
- f: ..-.
- g: --.
- h: ....
- i: ..
- j: .---
- k: -.-
- l: .-..
- m: --
- n: -.
- o: ---
- p: .--.
- q: --.-
- r: .-.
- s: ...
- t: -
- u: ..-
- v: ...-
- w: .--
- x: -..-
- y: -.--
- z: --..
Given a string consisting only of lowercase English letters, return its concatenated Morse-code representation.
Example:
Input: "gin"
Output: "--...-."
Follow-up: Given a Morse-code string with no separators between letters, generate all possible original lowercase strings that could have produced it.
Problem 2: Find Members Without Adequate Provider Access
You are given the following data:
- A list of
providers, where each provider has anid,specialty, and a 2Dlocation(e.g.,(x, y)). - A list of
members, where each member has anid, a 2Dlocation, and a list ofrequired_specialties. - A
max_distancevalue.
A member is considered to have adequate network access if, for every specialty they require, there is at least one provider of that specialty within max_distance of the member. The distance between locations should be calculated using Euclidean distance.
Your task is to return a list of member IDs who do not have adequate network access.
Example:
providers = [
{"id": 1, "specialty": "Cardiology", "location": (1, 2)},
{"id": 2, "specialty": "Dermatology", "location": (3, 4)}
]
members = [
{"id": 101, "location": (2, 3), "required_specialties": ["Cardiology", "Dermatology"]},
{"id": 102, "location": (10, 10), "required_specialties": ["Cardiology"]}
]
max_distance = 5
Output:
[102]