Pregunta de entrevista de Amazon

sorting question with array and minimum time complexity