So-Far interview question

Sorting and range display algorithm