XYZ Interview Question

Dsa question with linked list