206. Reverse Linked List
# Easy

Solution
temp records next node, head is current node, preNode is the pre-node of head. Don't forget to initialise preNode = NULL, return new head.
temp 记录下一个节点,head表示当前节点,preNode表示head的母节点。必须初始化preNode=NULL,并且最后返回新的头节点(即最后一个节点)。
record next node temporally
let head.next point to preNode
move to next node
暂时记录下一个节点
让head.next指向前一个节点
指针后移一位
Python syntax
Last updated
Was this helpful?