leetcode-Remove Duplicates from Sorted List-83
来源:互联网 发布:淘宝白菜qq群 微信群 编辑:程序博客网 时间:2024/04/27 13:52
删除重复的节点。只需要遍历一遍。
/** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; */class Solution {public: ListNode* deleteDuplicates(ListNode* head) { if(head==NULL) return head; int tmp=head->val; ListNode* p=head->next; ListNode* pre=head; while(p){ if(tmp==p->val){ ListNode* q=p->next; pre->next=p->next; p=q; } else{ tmp=p->val; pre=p; p=p->next; } } return head; }};
0 0
- LeetCode(83)Remove Duplicates from Sorted List
- [leetcode 83]Remove Duplicates from Sorted List
- [leetcode]83 Remove Duplicates from Sorted List
- [leetcode 83]Remove Duplicates from Sorted List
- leetcode-83 Remove Duplicates from Sorted List
- leetcode || 83、Remove Duplicates from Sorted List
- LeetCode 83 Remove Duplicates from Sorted List
- LeetCode---(83) Remove Duplicates from Sorted List
- leetcode 83 Remove Duplicates from Sorted List
- LeetCode 83:Remove Duplicates from Sorted List
- leetcode[83]:Remove Duplicates from Sorted List
- Leetcode[83]-Remove Duplicates from Sorted List
- Leetcode #83 Remove Duplicates from Sorted List
- leetcode 83: Remove Duplicates from Sorted List
- leetcode: (83) Remove Duplicates from Sorted List
- [Leetcode]#83 Remove Duplicates from Sorted List
- LeetCode 83 - Remove Duplicates from Sorted List
- [LeetCode-83] Remove Duplicates from Sorted List
- 剑指Offer----面试题21:包含min函数的栈
- MediaPlayer-循环播放音频文件
- 使用IntelliJ IDEA创建SpringMVC项目
- ZeroNet框架(ZeroFrame)API参考
- AsyncTask,Handler,EventBus三者的对比
- leetcode-Remove Duplicates from Sorted List-83
- 展望未来,总结过去10年的程序员生涯,给程序员小弟弟小妹妹们的一些总结性忠告
- 解决跨浏览器的事件问题
- 虚拟机下安装ubuntu后root密码设置
- 232. Implement Queue using Stacks [easy] (Python)
- caffe源码解析 — blob.cpp
- 判断单链表是否带环?若带环,求环的入口点?
- iOS 订单 物流接口数据的处理
- PAT - L1-020. 帅到没朋友(裸并查集)