Created
June 24, 2020 12:50
-
-
Save vamsitallapudi/0f3ebcb1541866aeec968c6dbb4545e5 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 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