BrowserStack Interview Question

Sort an array having N elements where every element is < N. The array has no duplicate values.

Interview Answers

Anonymous

Feb 23, 2017

Well this is a simple one where there index can be found using % N and place the value in that index to sort it.

2

Anonymous

Jul 14, 2016

If every element is less than N and there are no duplicates, that means elements are between 0 and N-1 inclusive. Just store them in order.

Anonymous

Jul 8, 2016

Count sort