Solve Morse and Network Access Tasks
OscarSoftware Engineer · OnsiteLast updated
This question evaluates string encoding/decoding and combinatorial parsing skills (Morse code conversion and ambiguous decoding) alongside spatial search and filtering competencies for proximity-based access checks, testing algorithmic reasoning, pattern recognition, backtracking possibilities, distance computation, and data-structure use.
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 2Dlocation. - A list of members, where each member has an
id, 2Dlocation, and a list ofrequired_specialties. - A
max_distancevalue.
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]
Solution walkthrough is for members
Get the full walkthrough with reference code and complexity analysis, plus Kitty Coach at 300 messages a day. Hints, the code runner and community answers stay free.