Question DSA-LL-0009
MediumWhat is the output of this code?
class Node:
def __init__(self, v, nxt=None):
self.v, self.next = v, nxt
head = Node(1, Node(2, Node(3, Node(4, Node(5)))))
slow = fast = head
while fast and fast.next:
slow, fast = slow.next, fast.next.next
print(slow.v)
- A.
4
- B.
5
- C.
Sign up free to see the answer and a step-by-step explanation.