Wrong output
PALINDROME LINKED LIST
You have to check for all the elements in the linked list. Simply checking the head won’t be of any use because you are just checking one element.
Let the linked list be -> 1 2 3 1
It is not a palindrome.
but while after reversing the linked list original linked list is also changing
In line 31, remove ‘&’. Don’t pass it by reference.
Your build linked list function is wrong.
Please check this code and tell me if you are able to understand it.
I understood this one bu that is the issue in my logic
Insert function is correct i guess because before printing if we try revresing the linked list its showing correct output
Logic is more or less the same. Your linked list is not being made correctly. Approach this question step by step. First successfully make the linked list. Print it and check. Then move on to reversing it and check if its a palindrome.
And there is no need to pass by reference anywhere. You might end up changing the original linked list.