SHARE
TWEET

Untitled

a guest Jul 22nd, 2019 55 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. def nth_to_last_node(n,head):
  2.    
  3.     left_pointer = head
  4.     right_pointer = head
  5.    
  6.     for i in range(n-1):
  7.        
  8.         if not rightpointer.nextnode:
  9.             raise LookupError("Error: n is larger than the linked list")
  10.            
  11.         right_pointer = right_popinter.nextnode
  12.        
  13.     while right_pointrt.nextnode:
  14.         left_pointer = left_pointer.nextnode
  15.         right_pointer = right_pointer.nextnode
  16.        
  17.     return left_pointer
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top