劍指offer ——刪除鏈表中重複的節點

  解法: 在重新定義鏈表指針域的同時, 使用 delete 釋放了已刪除節點的內存空間。   class Solution { public: ListNode* deleteDuplication(ListNode* pHead) { if (pHead == nullptr || pHead->next == nullptr) { //平凡列表無重複,確保列表有兩個節點 r
相關文章
相關標籤/搜索