Path reconstruction · 5 minutes
Trace two equally short routes
Get feedback on your answer. No account needed.
What does this Python code print?
from collections import deque
roads = {"S": ["B", "A"], "A": ["T"], "B": ["T"], "T": []}
queue = deque(["S"])
parent = {"S": None}
while queue:
stop = queue.popleft()
for neighbor in roads[stop]:
if neighbor not in parent:
parent[neighbor] = stop
queue.append(neighbor)
print(parent["T"])
Enter the output on one line.
