
class Solution {public static ListNode deleteDuplicates(ListNode head) {//边界情况:空链表、单节点不用反转if(head == null || head.next == null)return head;ListNode thisNode = head;ListNode nextNode = head.next;ListNode tempNode;while(nextNode.next != null){//反转nextNode的指向tempNode = nextNode.next;nextNode.next = thisNode;//将thisNode和nextNode都各自推进一步thisNode = nextNode;nextNode = tempNode;}//循环结束后,最后一个节点即nextNode还未改变指向nextNode.next = thisNode;//head节点还未处理head.next = null;return nextNode;}}
