prev
as null
, curr
as head
, and next
as null
.curr
is null
:
a. Store the next node by setting next
to curr.next
.
b. Reverse the next
pointer of curr
by setting curr.next
to prev
.
c. Move prev
forward by setting it to curr
.
d. Move curr
forward to next
(the original next node).prev
will be pointing to the new head of the reversed list. Return prev
.