Skip to content

Instantly share code, notes, and snippets.

@imouaddine
Created November 10, 2014 22:34
Show Gist options
  • Save imouaddine/11d2682781ef5bc0945b to your computer and use it in GitHub Desktop.
Save imouaddine/11d2682781ef5bc0945b to your computer and use it in GitHub Desktop.
o(n2) without any temporary buffer
def remove_duplicates
unless head && head.next
return self
end
current = head
while(current)
runner = current.next
_previous = current
while(runner)
if runner.value == current.value
_previous.next = runner.next
else
_previous = runner
end
runner = runner.next
end
current = current.next
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment