TikTok interview question

Merge two lowest duplicates in an array until none left.