标签:pre ems return 用法 for 基本 div solution span
problem
Remove Duplicates from Sorted List
考察的是链表的基本用法。
code
/** * 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* cur = head; while(cur && cur->next)//null is error. { if(cur->val == cur->next->val) cur->next = cur->next->next; else cur = cur->next; // } return head; } };
参考
1. Remove Duplicates from Sorted List;
完
【leetcode】83-Remove Duplicates from Sorted List
标签:pre ems return 用法 for 基本 div solution span
原文地址:https://www.cnblogs.com/happyamyhope/p/10016100.html