Reverse a singly linked list

What are the time and space complexities of iteratively reversing a singly linked list in place?

Show hints (2)+
  1. Three pointers suffice (prev, curr, next).
  2. No auxiliary data structure is allocated.

Answer

Reveal answer →

$O(n)$ time, $O(1)$ space

Want the full step-by-step worked solution? It's part of Premium — along with a worked solution for every question in the bank.

Asked at: Citadel, IMC

Related questions