Airbnb interview question
Read continuously across a list of sound tracks with a buffered read method
- Company:
- Airbnb
- Type:
- Coding
- Difficulty:
- Medium
- Reported:
- November 18, 2026
Problem
Several sound track classes are already implemented. They may be different subclasses, but all inherit from a base sound track class that implements read(x, buf). Calling read(x, buf) writes the next x characters of that track's data into the buffer buf, continuing from where the previous call stopped. For example, if a track's data is "abcde", read(3, buf) writes "abc" and a following read(2, buf) writes "de".
Implement a sound track iterator class that is constructed with a list of tracks and also provides read(x, buf). It reads continuously from the list of tracks in order and must support reads that cross from one track into the next.
In Python, model buf as a list that the call appends characters to.
Example 1
Input: tracks = ["a", "bcd", "ef"]; read(2), read(1), read(3)
Output: "ab", "c", "def"
The first read takes "a" from track 1 and "b" from track 2, so reads cross track boundaries.
Constraints
- Not stated; ask the interviewer.
Reported by candidates or drawn from publicly available sources, and rewritten in our own words. Pathwise Prep does not publish confidential assessment content. Report a concern