Interleave Three Equal-Length Strings
Company: Upstart
Role: Software Engineer
Category: Coding & Algorithms
Difficulty: easy
Interview Round: Take-home Project
# Interleave Three Equal-Length Strings
Given three strings of equal length, build a result by taking the character at index `0` from each string, then the character at index `1` from each string, and so on.
### Function Signature
```python
def interleave_three(first: str, second: str, third: str) -> str:
...
```
### Example
```text
Input: first = "abc", second = "def", third = "ghi"
Output: "adgbehcfi"
```
### Constraints
- `0 <= len(first) == len(second) == len(third) <= 200_000`
- Inputs may contain arbitrary Unicode characters.
### Clarifications
- Preserve each input's character order.
- For three empty strings, return the empty string.
- Do not add separators.
- Inputs are guaranteed to have equal lengths.
### Hints
- Traverse corresponding positions together.
- Avoid repeated immutable-string concatenation if it makes the runtime quadratic in your language.
Quick Answer: Interleave three equal-length strings by taking the character at each index from the first, second, and third string in order. Preserve arbitrary Unicode characters, handle empty inputs, and build the result efficiently without quadratic repeated concatenation.
Given three equal-length strings, build a new string by appending the character at each index from the first, second, and third strings in that order. Preserve all Unicode characters and add no separators.
Constraints
- All three inputs are strings of equal length.
- The inputs may be empty.
- Characters may be arbitrary Unicode.
- Preserve each input's character order.
- Avoid repeated quadratic string concatenation.
Examples
Input: ("", "", "")
Expected Output: ''
Explanation: Three empty strings interleave to empty.
Input: ("abc", "def", "ghi")
Expected Output: 'adgbehcfi'
Explanation: The prompt example takes one character from each string per index.
Hints
- Traverse corresponding positions together.
- Append three characters per index to a list.
- Join the list once after the traversal.