Leetcode Problem.83—Remove Duplicates from Sorted List
来源:互联网 发布:淘宝发票抬头设置 编辑:程序博客网 时间:2024/06/11 20:36
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
.
My C++ solution!
/** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; */
ListNode* deleteDuplicates(ListNode* head) { vector<int> temp; if(head==NULL) return head; ListNode *p=head; ListNode *q; temp.push_back(p->val); while(p->next) { if(find(temp.begin(),temp.end(),p->next->val)!=temp.end()) { q =p->next->next; p->next=q; } else { temp.push_back(p->next->val); p=p->next; } } return head;}
0 0
- Leetcode Problem.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
- Git Server搭建
- 软件设计之自顶向下
- 【HDU】5247-找连续数(直接暴力)
- iOS显示隐藏状态栏
- Leetcode Problem.67—Add Binary
- Leetcode Problem.83—Remove Duplicates from Sorted List
- ueditor富文本
- C语言字节对齐
- springmvc下的基于token的防重复提交
- C++中const、volatile、mutable的用法
- log4net的简单应用
- SMB协议
- SIFT算法详解
- Leetcode Problem.88 —Merge Sorted Array