Given a singly linked list find if it is palindrome
Problem description :
Write a function to determine if a singly linked list is a palindrome.
Input : A linked list
Output : Boolean (true or false)
Approach 1: Reverse and compare the linked lists.
- Create a new copy of the linked list.
- Reverse the newly created linked list.
- Compare the original linked list with the reversed linked list.
Time Complexity :
- O(n) ; where n is the number of nodes in the linked list