✅ Easy Approch | count outgoing edges 🔢| solution in 10 lines ! ⚡
Intuition\n Describe your first thoughts on how to solve this problem. \n All we need to do is to count the number of outgoing edges from each node. \n And retu
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n* All we need to do is to count the number of outgoing edges from each node. \n* And return the node which has no outgoing edges.\n# Approach\n<!-- Describe your approach to solving the problem. -->\n1. create a map where\n    1. key : string -> name of the city\n    2. value : int -> number of outgoing edges from each city. \n2. for each element in the given paths list\n    1. increment the counter of the source city by 1.\n    2. insert the destination city in the map if it was not exist before.\n3. iterate over the map you have created. \n    1. if the second (number of outgoing edges) was zero\n        1. return the first (city name)\n4. return empty string if no existing solution. (this case will never happen)      \n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n1. O(n) where n is the size of the given paths. \n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n1. O(n) where n is the size of the given paths * 2.\n# Code\n```\n    #include <bits/stdc++.h>\n#pragma GCC optimize("O3")\n#pragma GCC optimize("Ofast", "inline", "ffast-math", "unroll-loops", "no-stack-protector")\n#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native", "f16c")\nstatic const auto DPSolver = []()\n{ std::ios_base::sync_with_stdio(false); std::cin.tie(nullptr); std::cout.tie(nullptr); return \'c\'; }();\nusing namespace std;\nclass Solution {\npublic:\n\nstring destCity(vector<vector<string>> &paths)\n{\n    DPSolver; \n    map<string, int> graph;\n    for (auto path : paths){\n        graph[path[0]]++; \n        graph[path[1]] = graph[path[1]]; \n    }\n    for (auto node : graph)\n        if(!node.second)\n            return node.first; \n    return "";\n    \n}\n};\n```
['Hash Table', 'String', 'Graph', 'C++']