Reverse Linked List

Linked lists · Preserve the next node before rewiring · Easy · about 18 min

Why it matters

Linked lists make pointer movement concrete and prepare you for trees and graphs.

How it connects

A stack changes order using extra memory. Here you change links directly with two references.

Try first

Draw prev, current, and next. What must be saved before current.next changes?

Interview cue

I reverse links in place with three references and a single O(n) pass.