You are viewing a single comment's thread. Return to all comments →
No need of extra node
function removeDuplicates(head) { if(head === null || head.next === null) return head; else { let currentNode = head; while(currentNode && currentNode.next) { if(currentNode.data === currentNode.next.data) { currentNode.next = currentNode.next.next; } else { currentNode = currentNode.next; } } return head; } }
Seems like cookies are disabled on this browser, please enable them to open this website
Delete duplicate-value nodes from a sorted linked list
You are viewing a single comment's thread. Return to all comments →
No need of extra node