Let's take the most basic linked list first-- one with two nodes. We need to reverse this.
Seems pretty easy, right? To reverse an entire linked list, simply reverse every pointer. If 1
is pointing at 2
, flip it so 2
should point to 1
.
Of course, there's complexities that lie ahead. But for now, that's the basis for:
SNIPPET
117 -> 2 -> 21 -> 6 -> 42 -> 10
becoming
SNIPPET
117 <- 2 <- 21 <- 6 <- 42 <- 10