Last active
March 24, 2016 17:14
-
-
Save kinduff/fd1a3d0995f54b558cc1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def removeAt(index) | |
prev = nil | |
node = @head | |
i = 0 | |
loop do | |
prev = node | |
node = node.next | |
i += 1 | |
break unless !node.nil? and i < index | |
end | |
if prev.nil? | |
@head = node.next | |
else | |
prev.next = node.next | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment