public static Node reverseList(Node node) {
Node last = null;
Node next = null;
while (node != null) {
next = node.next;
node.next = last;
last = node;
node = next;
}
return last;
}
网友评论