Question: Complete the function joinLinkedLists() to take in two nodes that represent the beginning of two Linked Lists, n1 and n2, and join these Linked Lists
Complete the function joinLinkedLists() to take in two nodes that represent the beginning of two Linked Lists, n1 and n2, and join these Linked Lists such that n2 is attached to the end of n1.
Example
n1: 100 -> 85 -> 75 -> 65
n2: 23 -> 22 -> 12 -> 10
joinLinkedLists(n1, n2)
# returns 100 -> 85 -> 75 -> 65 -> 23 -> 22 -> 12 -> 10
code:
class Node: def __init__(self, value): self.value = value self.next = None def joinLinkedLists(n1, n2): # TODO ?
class Node Problem 2 def _init__(self, value): self.value value self. next = None Complete the function joinLinkedLists() to take in two nodes that represent the beginning of two Linked Lists, n1 and n2, and join these Linked Lists such that n2 is attached to the end of nl. 4 6- def joinLinkedLists(n1, n2): Example nl: 100 -85 -75-> 65 n2: 23-22-12-10 # TOD0 #returns 100-> 85-> 75-> 65-> 23-> 22-> 12-> 10
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
