Facebook | Phone screen | Sorted Iterator
Difficulty: EASYCategory: InterviewExperienceFrequency: 1Asked On 2018-09-12Added By Anonymous
Source: Link
Company: Meta (Facebook)
Role: e4
Interview Stage: Phone Screen
Location: New York, NY
Year: unknown
Original Post Content:
Status: BS CS, 5 Years of Experience
Position: Software Engineer at Facebook
Location: New York, NY
Technical phone screen (1 hour):
Implement a sorted java iterator that returns a sorted list over k sorted lists.
class SortedIterator implements Iterator<Integer> {
public SortedIterator(List<List<Integer>> lists) {}
public boolean hasNext() {}
public Integer next() {}
}
Example:
Input:
[[1, 4, 5, 8, 9],
[3, 4, 4, 6],
[0, 2, 8]]
Output: 0, 1, 2, 3, 4, 4, 4, 5, 6, 8, 8, 9