Amazon Interview Question

sorting question with array and minimum time complexity