Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jianminchen/6f9ce8c0f4dc06e97125c7aec278ef48 to your computer and use it in GitHub Desktop.
Save jianminchen/6f9ce8c0f4dc06e97125c7aec278ef48 to your computer and use it in GitHub Desktop.
list of iterators interface implementation
Question:
A list of iterator, Iterator interface has two function, define a class with the input of a list iterator in the constructor, implement Iterator interface, output in descending order.
Interface Iterator
{
HasNext();
Next()
}
List<Iterator<T>>
For example, [1 2] [3 4 5] [7 8], output is [1 2 3 4 5 7 8]
Ideas?
Do I need to use minimum heap with size of list of iterator? Do I need to use merge k sorted list, using merge sort to lower time complexity O(klogk n)? Do I need to ask more questions on clarification? Each iterator should be sorted in ascending order, for example.
Many thanks,
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment