Problem :
Function that takes a head node and an integer value n and then returns the nth to last node in the linked list.
Solution :
class Node: def __init__(self, value): self.value = value self.nextnode = None def nth_to_last_node(n, head): node = head nodes = [] while node != None: nodes.append(node) node = node.nextnode return nodes[-n]