human
Can you provide a code to intersection point of two Linked Lists and the other steps required given the following:
Intersection point of two Linked Lists | Set 3 | Structure of a node of a Linked List.
.
Function to find the intersection point of the two Linked Lists.
Traverse the first linked list and multiply all values by - 1.
Update a . data.
Update a.
Traverse the second Linked List and find the value of the first node having negative value.
Intersection point.
Update b.
Function to create linked lists.
Linked List L1.
Linked List L2.
Driver Code"
How can the above be solved in Python?
assistant
#Here is code to intersection point of two Linked Lists and the other steps required.
 class Node :
	def __init__ ( self , d ) :
		self . data = d
		self . next = None
/ * Constructor * / def __init__ ( self , d ) :
	self . data = d
	self . next = None
def intersectingNode ( headA , headB ) :
	a = headA
	while ( a ) :
		a . data *= - 1
		a = a . next
	b = headB
	while ( b ) :
		if ( b . data < 0 ) :
			break
		b = b . next
	return b
def formLinkList ( head1 , head2 ) :
	head1 = Node ( 3 )
	head1 . next = Node ( 6 )
	head1 . next . next = Node ( 9 )
	head1 . next . next . next = Node ( 15 )
	head1 . next . next . next . next = Node ( 30 )
	head2 = Node ( 10 )
	head2 . next = head1 . next . next . next
	return head1 , head2
if __name__ == ' _ _ main _ _ ' :
	head1 , head2 = formLinkList ( None , None )
	print ( abs ( intersectingNode ( head1 , head2 ) . data ) )