Citadel Securities interview question

Leetcode medium level question about sorting