Eleviant Tech interview question

train ticket processing code, remove the largest sub-word from the string