Palindrome Linked List
Problem Determine whether a singly linked list is a palindrome in O(n) time and O(1) space.
Input / Output
- Input: head of singly linked list.
- Output: boolean.
Constraints
- Up to 10^5 nodes; the array-copy solution is O(n) space — the O(1)-space version is the ask.
Example
- 1→2→2→1 → true; 1→2 → false.
asked …