Easy CPP approach||beginner friendly
Intuition\nThe problem involves finding the destination city, which is the city without any outgoing path. We can approach this problem by first identifying all
**Intuition**\nThe problem involves finding the destination city, which is the city without any outgoing path. We can approach this problem by first identifying all cities with outgoing paths. Then, among the destination cities, we find the one that has no outgoing path.\n\n**Approach**\nInitialize a HashSet cities to store all cities with outgoing paths.\nIterate through the paths and add the starting city of each path to the cities set.\nIterate through the paths again and check the destination city of each path. If the destination city is not in the cities set, it means there is no outgoing path from that city, so return it as the destination city.\n\n**Complexity**\nTime complexity: The time complexity is O(n) because we iterate through the paths twice.\nSpace complexity: The space complexity is O(n) for storing the set of cities.\n\n# Code\n```\nclass Solution {\npublic:\n    string destCity(vector<vector<string>>& paths) {\n        unordered_set<string> cities;\n        for (const auto& path : paths) {\n            cities.insert(path[0]);\n        }\n\n        for (const auto& path : paths) {\n            const std::string& dest = path[1];\n            if (cities.find(dest) == cities.end()) {\n                return dest;\n            }\n        }\n\n        return "";\n    }\n};\n```
['C++']