Jun 122012
 

Write a function to check if a Singly linked list is a palindrome or not. For example, the linked list

2 -> 3 -> 4 -> 5 -> 4 -> 3 -> 2 is a palindrome
M -> A -> L -> A-> Y -> A -> L -> A -> M is a palindrome
2 -> 3 -> 4 -> 5 -> 4 -> 6 -> 2 is NOT a palindrome
K -> A -> M -> A -> L is NOT a palindrome

The function should take O(n) time in worst case. Continue reading »