Palindrome linke list

I did this by converting linked list into string, whats the better to do this ?

You can split the linked list about its mid-point into two parts. Reverse one of the Linked list and then compare it with the other linked list. This way you can check if the linked list is a palindrome.
1->2->3->2->1 will split to 1->2 and 2->1, then compare 1->2 with reverse of 2->1. (Case for odd length LL)
1->2->3->3->2->1 will split to 1->2->3 and 3->2->1 and then compare it similarly. (Case for even length LL)

1 Like

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.