使用递归反转单链表
2017-03-16 本文已影响329人
敲一手烂代码
class Node {
char value;
Node next;
}
public Node reverse(Node current)
{
if (current == null || current.next == null) return current;
Node nextNode = current.next;
current.next = null;
Node reverseRest = reverse(nextNode);
nextNode.next = current;
return reverseRest;
}