83. Remove Duplicates from Sorted List
来源:互联网 发布:sql注入检测工具 编辑:程序博客网 时间:2024/06/05 06:57
Given a sorted linked list, delete all duplicates such that each element appear onlyonce.
For example,
Given 1->1->2
, return 1->2
.
Given 1->1->2->3->3
, return 1->2->3
.
Subscribe to see which companies asked this question
代码:
/** * 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 * prepare=head; while(head && head->next) { if(head->val == head->next->val) { head->next=head->next->next; } else { head= head->next; } } return prepare; }};
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
- TSP问题之回溯算法
- HDU 1847 Good Luck in CET-4 Everybody!(博弈)
- latex排版论文(1)
- 随记,性能相关
- Error creating the view. An error occurred while automatically activating bundle
- 83. Remove Duplicates from Sorted List
- 【leetcode】14. Longest Common Prefix
- Java千百问_06数据结构(025)_用二进制如何表示浮点型数值
- Boost serialization
- 【SSH系列】初识spring+入门demo
- php smarty 是什么?
- hibernate---学习之二API
- Intel Edison arduino代码驱动OLED(SSD1306)
- MySql服务未知原因消失了的终极解决办法