legs but mixed up their order. Each leg is a pair [from, to]: the traveler went straight from the first city to the second.
All legs join into a single chain with no repeats and no loops, so every city appears on the route once. Return the name of the city where the trip ended, the one with no leg leaving it.legs=[['Oslo', 'Bergen'], ['Tromso', 'Oslo'], ['Bergen', 'Stavanger']] → 'Stavanger'
The route is Tromso → Oslo → Bergen → Stavanger. Nothing leaves Stavanger, so that is the last stop.
legs=[['Rome', 'Milan']] → 'Milan'
The only leg ends in Milan.
legs=[['b', 'B'], ['a', 'b']] → 'B'
Case matters: "b" and "B" are different cities. The route is a → b → B.
legs=[['Oslo', 'Bergen'], ['Tromso', 'Oslo'], ['Bergen', 'Stavanger']]
'Stavanger'
Run checks the first 3 tests in your browser. Submit checks all 69 tests on the server, hidden ones included.