Circular linked list assignment question

Here’s my code , https://ide.codingblocks.com/s/292895 . It passed one of test cases but is showing run time error for other two test cases . I don’t understand where the error is .

@harshit.t2409
Your code isn’t working for this testcase
1 2 3 4 -1
please dryrun your code for this testcase.