Question d’entretien chez TikTok

Merge two lowest duplicates in an array until none left.