Advertisement
1sairandhri

doubly linked list corruption

Apr 12th, 2020
651
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.34 KB | None | 0 0
  1. def solution(head, tail):
  2.     """
  3.    inputs: head and tail node
  4.    outputs: True - if there's no corruption, False - corruption exists
  5.  
  6.    """
  7.     if head.prev!=None or tail.next!=None:
  8.         return False
  9.    
  10.     while head.next:
  11.         if head!=head.next.prev:
  12.             return False
  13.         head = head.next
  14.     return True
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement