✅ Navigating Urban Labyrinths: Elegant Solution to Find the Destination City 🔥
Description\n\n## Intuition\nThe problem requires finding the destination city, which is the city without any outgoing path to another city. The graph is guaran
# Description\n\n## Intuition\nThe problem requires finding the destination city, which is the city without any outgoing path to another city. The graph is guaranteed to form a line without any loops.\n\n## Approach\nThe solution uses a dictionary (`check`) to keep track of whether a city is an "out" city (has an outgoing path) or an "in" city (has an incoming path). It iterates through the given paths, updating the status of each city accordingly. Finally, it looks for the city with an incoming path, which is the destination city.\n\n## Complexity\n- **Time complexity:** O(n), where n is the number of paths. The algorithm iterates through the given paths once.\n- **Space complexity:** O(n), where n is the number of paths. The space is used to store the status of each city in the dictionary.\n\n## Code\n```csharp []\npublic class Solution {\n    public string DestCity(IList<IList<string>> paths)\n    {\n        Dictionary<string, string> check = new Dictionary<string, string>();\n\n        foreach(var path in paths)\n        {\n            check[path[0]] = "out";\n            if (!check.ContainsKey(path[1]))\n            {\n                check[path[1]] = "in";\n            }\n        }\n\n        foreach (var item in check.Keys)\n        {\n            if (check[item] == "in") return item;\n        }\n\n        return "";\n    }\n}\n```\n```java []\npublic class Solution {\n    public String destCity(List<List<String>> paths) {\n        HashMap<String, String> check = new HashMap<>();\n\n        for (List<String> path : paths) {\n            check.put(path.get(0), "out");\n            if (!check.containsKey(path.get(1))) {\n                check.put(path.get(1), "in");\n            }\n        }\n\n        for (String item : check.keySet()) {\n            if ("in".equals(check.get(item))) {\n                return item;\n            }\n        }\n\n        return "";\n    }\n}\n```\n```python []\nclass Solution:\n    def destCity(self, paths: List[List[str]]) -> str:\n        check = {}\n\n        for path in paths:\n            check[path[0]] = "out"\n            if path[1] not in check:\n                check[path[1]] = "in"\n\n        for item in check:\n            if check[item] == "in":\n                return item\n\n        return ""\n```\n\n![image name](https://i.imgur.com/JdL5kBI.gif)\n\n- Please upvote me !!!
['Java', 'Python3', 'C#']