XYZ interview question

Dsa question with linked list