# 83. Remove Duplicates from Sorted List

`Input: head = [1,1,2]Output: [1,2]`
`Input: head = [1,1,2,3,3]Output: [1,2,3]`
`/** * 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) {                int vn = {0};                int vp = {0};                ListNode *prev = head;                ListNode *curr = head;                while(curr!=NULL){                        if(curr->val > 0 && vp[(curr->val)] == 1){                prev->next = curr->next;                curr = curr->next;                continue;            }                        if(curr->val <= 0 && vn[-(curr->val)] == 1){                prev->next = curr->next;                curr = curr->next;                continue;            }                        if(curr->val <= 0 ){                vn[-(curr->val)] = 1;                prev = curr;                curr = curr->next;            }            else if(curr->val > 0 ){                vp[(curr->val)] = 1;                prev = curr;                curr = curr->next;            }}                return head;    }};`
1. If the array[val] == 1, we move the node that has the same value, then continue to next round.

--

--