public class Node {
Object value;
Node next;
public Node(Object value) {
this.value = value;
}
}
void reverse(Node head) {
Node previous = null;
if (head == null) {
return;
}
while (head != null) {
Node nextNode = head.next;
head.next = previous;
previous = head;
head = nextNode;
}
}
单项链表 反转
最新推荐文章于 2024-09-10 10:21:38 发布