83. Remove Duplicates from Sorted List
来源:互联网 发布:mvvm数据绑定原理 编辑:程序博客网 时间:2024/06/16 05:04
题目
Given a sorted linked list, delete all duplicates such that each element appear only once.
For example,
Given 1->1->2
, return 1->2
.
Given 1->1->2->3->3
, return 1->2->3
.
当前结点与下一个结点值比较。
/** * 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; ListNode* temp_head=head; while(head->next!=NULL) { if(head->val==head->next->val) { head->next=head->next->next; } else head=head->next; } return temp_head; }};
0 0
- [LeetCode]83.Remove Duplicates from Sorted List
- 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
- 83. Remove Duplicates from Sorted List
- LeetCode 83. Remove Duplicates from Sorted List
- 83. Remove Duplicates from Sorted List
- 【leetcode】83. Remove Duplicates from Sorted List
- 83. Remove Duplicates from Sorted List
- 83. Remove Duplicates from Sorted List LeetCode
- 83. Remove Duplicates from Sorted List
- leetcode 83. Remove Duplicates from Sorted List
- 83. Remove Duplicates from Sorted List
- 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
- jni备忘:jni调用java方法显示一个Dialog
- MTK 电池曲线配置
- 利用 Composer 完善自己的 PHP 框架(一)——视图装载
- 对“仅通过崩溃地址找出源代码的出错行”一文的补充与改进
- GCD实现倒计时且后台运行不影响计数
- 83. Remove Duplicates from Sorted List
- 到底什么是消息队列?Java中如何实现消息队列?
- jasperreport报表预览内容自动换行
- 开源项目AndroidReview学习小结(2)
- git基本
- iOS开发~FMDB的使用
- xhost命令介绍
- UVA 11552Fewest Flops 【区间dp】
- (六)RxJava轮询器:interval