Yandex interview question

DSA Round. Revert some part of linked list