2 test cases are giving out run error

For Palindrome Linked List check ,

2 test cases are giving me run error .
What changes should be made in the code in order to pass these test cases and what are the errors in my code ?

Here is the link to my code -

Hello @Vishesh-Chaitanya-1475805525886480 please wait i am checking your logic.

I took the input linked list and i reversed it .

and then i compared the input linked list with the reverse one . if the elements of the linked list while traversing in forward direction come out to be same , then ig we could call it a palindrome otherwise it’s not

@Vishesh-Chaitanya-1475805525886480when you are reversing the list then the orginal list is also being affected.
wait i am correcting it.

@Vishesh-Chaitanya-1475805525886480 if you will reverse the linked list then it will always disturb the original linked list:


you can check this code i have written acoording to your logic in which i am adding the nodes at the head instead of heading at tail so instead of reversiing the linked list you can form another in this way and then it can help you compairing.