<p>Given the <code>head</code> of a sorted linked list, <em>delete all duplicates such that each element appears only once</em>. Return <em>the linked list <strong>sorted</strong> as well</em>.</p>

<p>&nbsp;</p>
<p><strong class="example">Example 1:</strong></p>
<img alt="" src="https://assets.leetcode.com/uploads/2021/01/04/list1.jpg" style="width: 302px; height: 242px;" />
<pre>
<strong>Input:</strong> head = [1,1,2]
<strong>Output:</strong> [1,2]
</pre>

<p><strong class="example">Example 2:</strong></p>
<img alt="" src="https://assets.leetcode.com/uploads/2021/01/04/list2.jpg" style="width: 542px; height: 222px;" />
<pre>
<strong>Input:</strong> head = [1,1,2,3,3]
<strong>Output:</strong> [1,2,3]
</pre>

<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>

<ul>
	<li>The number of nodes in the list is in the range <code>[0, 300]</code>.</li>
	<li><code>-100 &lt;= Node.val &lt;= 100</code></li>
	<li>The list is guaranteed to be <strong>sorted</strong> in ascending order.</li>
</ul>

/**
 * 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* mover=head->next;
        ListNode* point=head;
        while(mover){
              if(mover->val== point->val){
                ListNode*temp=mover;
                mover=mover->next;
                delete temp;
                
              }
               if(mover==NULL) {
                point->next=NULL;
                break;}
              if(mover->val!=point->val){
                point->next=mover;
                mover=mover->next;
                point=point->next;
              }
                  if(mover==NULL) point->next=NULL;
        }
        return head;
    }
};
static const int __ = [](){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    return 0;
}();

int init = [] {
    ofstream out("user.out");
    cout.rdbuf(out.rdbuf());
    for (string str; getline(cin, str); cout << '\n') {
        set<int> s;
        stringstream ss(str); ss.ignore();
        int prev = INT_MIN;
        bool first = true;
        cout << '[';
        for (int i; ss >> i; ss.ignore()) {
            if (i != prev) {
                if (first) {
                    cout << i;
                    first = false;
                } else {
                    cout << ',' << i;
                }
                prev = i;
            }
        }
        cout << ']';
    }
    exit(0);
    return 0;
}();
7600