Quant Memo
Coding/●●●●●

Is a linked list a palindrome, in constant space?

Given the head of a singly linked list, decide whether the sequence of values is a palindrome.

1 -> 2 -> 2 -> 1        -> True
1 -> 2 -> 3 -> 2 -> 1   -> True
1 -> 2                  -> False

Do it in O(n)O(n) time and O(1)O(1) extra space. Copying values into a Python list and comparing is O(n)O(n) space; the point is to reuse the reversal trick.

Your answer

This one is open-ended. Work it through, then check your reasoning against the full solution.

More Coding questions