Skip to content

Instantly share code, notes, and snippets.

@vamsitallapudi
Created June 24, 2020 12:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vamsitallapudi/0f3ebcb1541866aeec968c6dbb4545e5 to your computer and use it in GitHub Desktop.
Save vamsitallapudi/0f3ebcb1541866aeec968c6dbb4545e5 to your computer and use it in GitHub Desktop.
def delete_at_pos(head, position):
if not head:
return None
if position is 0:
return head.next
prev_node = head
curr_node = head.next
current_pos = 1
while curr_node and current_pos < position:
current_pos += 1
prev_node = prev_node.next
curr_node = curr_node.next
prev_node.next = curr_node.next
return head
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment