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".

///

///

/// The destination city string

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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!