/**
* 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) {
if (head == null) return head;
ListNode run = head;
while(run.next != null){
if (run.val == run.next.val){
run.next = run.next.next;
}else{
run = run.next;
}
}
return head;
}
}
Remove Duplicates from Sorted List
最新推荐文章于 2019-02-12 17:27:05 发布