Question
/// /// You are given the array paths, where paths[i] = [cityAi, cityBi] means there exists a direct path going from cityAi to cityBi. Return
///
/// You are given the array paths, where paths[i] = [cityAi, cityBi] means there exists a direct path going from cityAi to cityBi. Return the destination city, that is, the city without any path outgoing to another city.
/// It is guaranteed that the graph of paths forms a line without any loop, therefore, there will be exactly one destination city.
/// Example 1:
/// Input: paths = [["London", "New York"], ["New York","Tampa"], ["Delhi","London"]]
/// Output: "Tampa"
/// Explanation: Starting at "Delhi" city you will reach "Tampa" city which is the destination city.Your trip consist of: "Delhi" -> "London" -> "New York" -> "Tampa".
/// Input: paths = [["B","C"],["D","B"],["C","A"]]
/// Output: "A"
/// Explanation: All possible trips are:
/// "D" -> "B" -> "C" -> "A".
/// "B" -> "C" -> "A".
/// "C" -> "A".
/// "A".
/// Clearly the destination city is "A".
///
///
///
private static string DestCity(string[,] paths)
{
try
{
// write your code here.
return "";
}
catch (Exception)
{
throw;
}
}
}
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started