Solve the following two independent coding problems.
Problem 1: Convert Between Text and Morse Code
You are given 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 the concatenated Morse-code representation of the string.
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:
-
A list of providers, where each provider has an
id
,
specialty
, and 2D
location
.
-
A list of members, where each member has an
id
, 2D
location
, and a list of
required_specialties
.
-
A
max_distance
value.
A member has adequate network access if, for every specialty they require, there is at least one provider of that specialty within max_distance of the member. Use Euclidean distance between locations.
Return the 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]