Answer: Toshiba Hiring Challenge | Problem Destination City | Off-Campus OA (2022)
Answer · Posted Jun 2026
Approach Store every city that appears as a starting city. Traverse the destination cities. The city that never appears as a starting city is the destination. Strategy Create a HashSet for all source cities. Add every starting city into the set. Traverse the destination cities. Return the destination city not present in the set. Java Code import java.util.*; class Solution { public String destCity(List<List<String>> paths) { Set<String> hasOutgoing = new HashSet<>(); for (List<String> path : paths) hasOutgoing.add(path.get(0)); for (List<String> path ...
The full answer & interview discussion are available to premium members.
Log in Create a free account