Google | Phone | Sorted Iterator
Anonymous User
1980

Given K sorted lists, write a function in Javascript to print next() minimum element from the list.

const s = new SortedIterator[[1, 2, 4] [2, 3, 4] [1, 5, 6]]
Output:
s.next(); // 1
s.next(); // 1
s.next(); // 2
s.next(); // 2
s.next(); // 3
s.next(); // 4
s.next(); // 4
s.next(); // 5
s.next(); // 6

Note: I have been asked to implement in Javascript, maybe because I chose coding in Javascript.

Comments (5)