TikTok Interview Question

Merge two lowest duplicates in an array until none left.