static Node reverselinkedList(Node node) { Node previousNode = null; Node currentNode = node; Node headNode = null; while (currentNode != null) { Node nextNode = currentNode.next; if (nextNode == null) { headNode = currentNode; } currentNode.next = previousNode; previousNode = currentNode; currentNode = nextNode; } return headNode;}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)