remove-duplicates-from-sorted-list
Posted 笨鸟居士的博客
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了remove-duplicates-from-sorted-list相关的知识,希望对你有一定的参考价值。
https://leetcode.com/problems/remove-duplicates-from-sorted-list/
public ListNode deleteDuplicates(ListNode head) { int last = -1; ListNode store = null; ListNode cur = head; while (cur != null) { if (store == null) { store = head; } else if (cur.val != last) { store = store.next; store.val = cur.val; } last = cur.val; cur = cur.next; } if (store != null) { store.next = null; } return head; }
以上是关于remove-duplicates-from-sorted-list的主要内容,如果未能解决你的问题,请参考以下文章