Goldman Sachs interview question

DSA Question on sorting. Along with some optimization techniques