/**
* Definition for singly-linked list.
* public class ListNode {
* int val;
* ListNode next;
* ListNode(int x) {
* val = x;
* next = null;
* }
* }
*/
public class Solution {
public ListNode deleteDuplicates(ListNode head) {
ListNode headPointer = head;
if(null == head)
return null;
while(null != headPointer.next){
if(headPointer.val == headPointer.next.val)
headPointer.next = headPointer.next.next;
else
headPointer = headPointer.next;
}
headPointer = null;
return head;
}
}
Remove Duplicates from Sorted List
最新推荐文章于 2023-01-13 08:10:00 发布