标签:反转 lin nod link class pre 链表反转 next value
/**
* 单向链表反转
*/
public class RevertLinkedNode {
public static class Node<T> {
public T value;
public Node next;
public Node(T node) {
this.value = node;
}
}
public static Node revertNode(Node node) {
Node pre = null;
Node next = null;
while (node != null) {
next = node.next;
node.next = pre;
pre = node;
node = next;
}
return pre;
}
}
标签:反转 lin nod link class pre 链表反转 next value
原文地址:https://www.cnblogs.com/laydown/p/12790414.html