BrowserStack interview question

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

Interview Answers

Anonymous

23 Feb 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

8 Jul 2016

Count sort

Anonymous

14 Jul 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.