Goldman Sachs Interview Question

Strange sorting problem