Pregunta de entrevista de TikTok

An unsorted array problem using any language to solve.