Bloomberg Interview Question

welsh alphabet sorting problem on hackerrank