Bloomberg interview question

welsh alphabet sorting problem on hackerrank