Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def solution(head, tail):
- """
- inputs: head and tail node
- outputs: True - if there's no corruption, False - corruption exists
- """
- if head.prev!=None or tail.next!=None:
- return False
- while head.next:
- if head!=head.next.prev:
- return False
- head = head.next
- return True
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement