Rat Chases its cheese - Linked List

My code is not able to pass the first two test cases. I do not know where I am doing wrong. Plz help
My code