Ładowanie zadania…
Imagine a chain of trips: you travel from one city to the next, then farther again, until the route ends. Write a function destination_city that receives a list of [from, to] route pairs and finds the city with no outgoing route. Return the name of that final city. It is guaranteed that all routes form one path without loops.
[["London", "New York"], ["New York", "Lima"], ["Lima", "Sao Paulo"]]"Sao Paulo"[["B", "C"], ["D", "B"], ["C", "A"]]"A"[["A", "Z"]]"Z"def destination_city(paths: list[list[str]]) -> str:
Zaloguj się, aby zobaczyć historię rozwiązań
Zaloguj sięZaloguj się, aby korzystać z Mentora AI
Zaloguj sięThey run when you press "Submit" — your whole solution is checked against them so you can't hard-code answers for the visible cases.