Pergunta de entrevista da empresa TikTok

An unsorted array problem using any language to solve.