remove-duplicates-from-sorted-list
来源:互联网 发布:淘宝店铺找谁可以装修 编辑:程序博客网 时间:2024/05/21 20:30
题目:
Given a sorted linked list, delete all duplicates such that each element appear only once.
For example,
Given1->1->2, return1->2.
Given1->1->2->3->3, return1->2->3.
程序:
class Solution {
public:
ListNode *deleteDuplicates(ListNode *head) {
if(head==NULL)
return head;
if(head->next==NULL)
return head;
ListNode *p=head,*q=head->next;
while(q) { if(q->val==p->val) { q=p->next->next; p->next=q; } else { p=q; q=q->next; } } return head;}
};
阅读全文
0 0
- Remove Duplicates from Sorted List
- Remove Duplicates from Sorted List
- Remove Duplicates from Sorted List
- Remove duplicates from sorted list
- Remove Duplicates from Sorted List
- Remove Duplicates from Sorted List
- Remove Duplicates from Sorted List
- Remove Duplicates from Sorted List
- Remove Duplicates from Sorted List
- Remove Duplicates from Sorted List
- Remove Duplicates from Sorted List
- Remove Duplicates from Sorted List
- Remove Duplicates from Sorted List
- Remove Duplicates from Sorted List
- Remove Duplicates from Sorted List
- Remove Duplicates from Sorted List
- Remove Duplicates from Sorted List
- Remove Duplicates from Sorted List
- Flume
- python基础:(2)第一个程序
- Bootstrap模态对话框中显示动态内容
- 9月21日云栖精选夜读:专访新浪微博黄波:千人千面,机器学习赋能用户信息流消费
- 汉诺塔问题
- remove-duplicates-from-sorted-list
- springjdbc的使用
- [RK3288][Android6.0] 调试笔记 --- 播放GIF动画卡顿问题
- 读《印象笔记超效率数位笔记术》
- python:(2)数据类型和变量
- InetAddress类的使用
- apache做反向代理服务器
- 数据库——Oracle中的通配符
- 如何适配iOS11和iPhoneX