ABC interview question

Linked list related sorting problem