5.Palindrome Linked List
Last updated
Last updated
Given the head
of a singly linked list, return true
if it is a palindrome.
Example 1:
Example 2:
Optimized solution:-
This solution uses Time Complexity O(n) and Space Complexity O(1).
Reverse the part of the linked list.
Iterate over the 1st part and second part an compare the elements.
Other Solution:-
Copying all the elements to an array and checking if the array is palindrome. This method uses an extra space complexity of O(n).