Circular Linked List

My code is not passing two
test cases,please help .

Your code is failing for the test cases like:
1 2 3 4 5 1 -1

Cross check your code with this case.