c盤(pán)清理的步驟是什么(如何清理C盤(pán)空間)
如何清理C盤(pán)空間怎么清理C盤(pán)的垃圾文件?每天上網(wǎng)會(huì)給電腦帶來(lái)很多臨時(shí)文件,這些垃圾文件不清理掉時(shí)間久了就會(huì)影響到電腦的運(yùn)行速度。那怎
2022/12/08
(資料圖片)
題目:
編寫(xiě)代碼,移除未排序鏈表中的重復(fù)節(jié)點(diǎn)。保留最開(kāi)始出現(xiàn)的節(jié)點(diǎn)。
示例1:
輸入:[1, 2, 3, 3, 2, 1]
輸出:[1, 2, 3]
示例2:
輸入:[1, 1, 1, 1, 2]
輸出:[1, 2]
代碼實(shí)現(xiàn):
class Solution { public ListNode removeDuplicateNodes(ListNode head) { if (head == null) { return head; } Setoccurred = new HashSet (); occurred.add(head.val); ListNode pos = head; // 枚舉前驅(qū)節(jié)點(diǎn) while (pos.next != null) { // 當(dāng)前待刪除節(jié)點(diǎn) ListNode cur = pos.next; if (occurred.add(cur.val)) { pos = pos.next; } else { pos.next = pos.next.next; } } pos.next = null; return head; }}
標(biāo)簽: 刪除節(jié)點(diǎn)