Pergunta de entrevista da empresa Amazon

sorting question with array and minimum time complexity