Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # solution
- # set the next value to the current middle node
- # set the next next node to middle node's next
- # if the final node, set to None
- # O(1) in time, O(1) in space
- def solution(node):
- if node.next != None:
- node.value = node.next.value
- node.next = node.next.next
- else:
- node.value = None
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement