Search
 
SCRIPT & CODE EXAMPLE
 

CPP

remove duplicates from sorted list leetcode solution in c++

/**
 * Definition for singly-linked list.
 * struct ListNode {
 *     int val;
 *     ListNode *next;
 *     ListNode() : val(0), next(nullptr) {}
 *     ListNode(int x) : val(x), next(nullptr) {}
 *     ListNode(int x, ListNode *next) : val(x), next(next) {}
 * };
 */
class Solution {
public:
    ListNode* deleteDuplicates(ListNode* head) {
        if(head == NULL || head->next == NULL) 
            return head;
        ListNode* temp=head;
        ListNode* cur=head->next;
        while(cur!=NULL)
        {
            if(cur->val==temp->val)
            {
               temp->next=cur->next;
            }else 
            {
                temp=cur;
            }
            cur=cur->next;
        }
        return head;
    }
};
Comment

PREVIOUS NEXT
Code Example
Cpp :: substring function in c++ 
Cpp :: create a copy of a vector c++ 
Cpp :: c++ add everything in a vector 
Cpp :: how to show constellations in starry night orion special edition 
Cpp :: ue4 endoverlap c++ 
Cpp :: Round 1 Confusion codechef solution in c++ 
Cpp :: c++ download 
Cpp :: enter items in array until enter is pressed c++ 
Cpp :: pointer to value of others file cpp 
Cpp :: stack implementation 
Cpp :: faster solutions 
Cpp :: curl upload folder and subfolders 
Cpp :: c++ graphics online compiler 
Cpp :: right rotation of array in c++ by one element 
Cpp :: nmake.exe is not found in the windows 
Cpp :: c++ program to convert fahrenheit to kelvin 
Cpp :: C++ for vs while loops 
Cpp :: class how to call main method inheritance in c++ 
Cpp :: Shuffle String leetcode solution in cpp 
Cpp :: Link List Insertion a node 
Cpp :: sinh nhi phan c++ 
Cpp :: contains in c++ map 
Cpp :: assegnare valori in c++ 
Cpp :: int to string Using boost::lexical_cast 
Cpp :: segment tree lazy propogation 
Cpp :: std remove example 
Cpp :: how to get steam id c++ 
Cpp :: how to merge string array in C++ 
Cpp :: rand() and srand() in C/C++ 
Cpp :: c++ CRL multiline string 
ADD CONTENT
Topic
Content
Source link
Name
3+8 =