[JS] O(n) time, O(1) space with explanation
Approach:\nIn this problem, there are 3 cases to consider mainly\n1. duplicates in the beginning - need to set a new head.\n2. duplicates in between and at the 
Approach:\nIn this problem, there are 3 cases to consider mainly\n1. duplicates in the beginning - need to set a new `head`.\n2. duplicates in between and at the end of the list.\n3. unique value\n\nBasically, we start by checking values of the two adjacent nodes. If the values are equal (duplicates) -\n1. for case 1, we did not have a prior node with unique value, the current node will basically be the first possible node encountered with a unique value (`possible` since after traversing further nodes, this node could also be having duplicate value). So we set this as the new node as head.\n2. for case 2, we will have encountered a prior node with a unique value already, so we set the next pointer of that node as the current node.\n3. for case 3, we set the prev node as the current node and move to the next node.\n\n```\nvar deleteDuplicates = function(head) {\n    let curr = head,\n        prev = null;\n    while(curr && curr.next) {\n\t\t// if current node and next node value are same,\n\t\t// iterate until we get to the node which does not have the same value as these 2 nodes\n        if(curr.val === curr.next.val) {\n            while(curr && curr.next && curr.val === curr.next.val) {\n                curr = curr.next;\n            }\n\t\t\t// the above loop will stop at the last duplicate node, for instance for 1,1,1,2,...\n\t\t\t// the loop will stop at 3rd node from start with value 1\n\t\t\t// so we move to next node which is not part of the previous set of duplicates\n            curr = curr.next;\n\t\t\t\n\t\t\t// if no prev unique value node is encountered, set the `head` to this node\n            if(!prev) {\n                head = curr;\n            } else {    // if there is a prev unique value node, reset it\'s next pointer\n\t\t\t\t// we do not change the prev node, since the current node itself can be having duplicate value\n\t\t\t\t// so we will process the current node, until we identify it as having a unique value\n                prev.next = curr;    \n            }\n        } else {    // node is having unique value\n\t\t\t// set prev as the current node and move to the next node\n            prev = curr;\n            curr = curr.next;    \n        }\n    }\n    return head;    // finally return the head\n};\n```\n\nTime Complexity = O(n)\nSpace Complexity = O(1)\n\nTest Cases for dry run:\n```\n[1,2,3,3,4,4,5]      // duplicates in between\n[1,1,1,2,2,2,3,4]    // duplicates at the beginning\n[1,2,3,4,4,4]        // duplicates at the end\n[1,1,2,2,3,3]        // all duplicates\n[]                   // empty list\n[1]                  // only one node\n[1,1]                // only two nodes (duplicates)\n[1,2]                // only two nodes (no duplicates)\n```
['JavaScript']