- Get the middle of the linked list.
- Reverse the second half of the linked list.
- Compare the first half and second half.
- Construct the original linked list by reversing the second half again and attaching it back to the first half.
Time complexity: O(n)
Space complexity: O(1)
No comments:
Post a Comment