leetcode 83: Remove Duplicates from Sorted List
2015-08-07 22:32
281 查看
/** * 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) { ListNode* curr=head; while(curr&&curr->next) { if(curr->val==curr->next->val) { ListNode* temp=curr->next; curr->next=curr->next->next; delete temp; } else curr=curr->next; } return head; } };
相关文章推荐
- Python requests库解析中文网页乱码处理方法
- Nginx 学习笔记二
- Oracle学习之DATAGUARD(十一) snapshot database
- 学习JavaBean 遇到的问题
- HTML与CSS_基础 翁恺 笔记(2015.8.10更新)
- linux下无线网卡驱动安装
- 机器视觉开源代码集合
- ZOJ2562
- [欧拉计划]Problem 1.Multiples of 3 and 5
- BootStrap模态框
- UVA673 Parentheses Balance
- Struts.xml讲解
- 九度oj 1461
- Nginx+tomcat7的负载均衡和动静分离配置
- POJ2909
- Java基础——IO流(四)
- hdu 1698 Just a Hook(线段树区间更新·经典)
- Python字符串操作之字符串搜索与替换
- HTML与CSS_基础 翁恺 笔记(2015 8.10更新)
- Struts2配置文件模板