[Oracle technical discussion]Sorting stream of integer Design a lib/api[2yrs exp.]
Anonymous User
883

Recently I appeared for an interview and a question was asked in this way:

you are reciving stream of integers at very high speed. The client has 2 requirements 1. to get the list of integer int order being consumed 2. You should be able to return sort list of integer when client ask for sorted list.

  1. int[] getListofInteger()
  2. int[] getSortedListofInteger()

How you will design this ?
Which data structure you would use to design this requirement ?
can you do better that sorting of array list every time when you get request i.e can we do it without heavy operation or sorting O(nlogn).

Any knowledge share or insights to tackle these kind of question would help me . Thanks in advance.

Comments (1)