Leetcode 83

/**
 * 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* move;
        move = head;
        while(move->next != NULL){
            if(move->val == move->next->val){
                move->next = move->next->next;
            }
            else{
                move = move->next;
            }
        }
        return head;
    }
};
水题

猜你喜欢

转载自www.cnblogs.com/cunyusup/p/9926591.html
今日推荐