A sorted array of length n with all integers from 0 to n-1 will *always* be {0, 1, 2, 3, 4, ... n-2, n-1} So one way to "sort" this problem in a C style language is the following: for(int i = 0; i < n; i++) arr[i] = i; Also of course, I've never actually been in a coding interview, but I imagine if I was I'd also ask pertinent questions like if this actually counts as sorting, make sure there aren't any potential complications with non-primitive Integer types, etc.