During the interview I was asked the following question:
We have a client application that can send a request and receive a data stream from int (possibly large, but less than INT_MAX). We must do this:
Int Data ----> Our ----> Sorted Int Data
Stream App Data Stream
So, I would write a method as follows:
public int[] sort(int[] array){
Arrays.sort(array);
return array;
}
The problem is that the big array
one cannot fit on the stack and will be pushed onto the heap , which reduces performance. How to reorganize it with good quality ?
source
share