What is wrong in my code?

if i am trying in my development it is working fine but on leetcode its giving wrong answer.

We have to check whether list is plaindrome or not.

for 1,2,3,2,1 ; 1,2,21; 3,4,5,4,3
answer is coming right but for 1,2; 1,3,2,4,1 it is coming wrong.