3 quick and easy to remember methods with explanation
3 Easy to remember methods\nMethod 1: Intuitive\nStep 1: Let\'s keep a track of unique entries in source cities (cityA) and the intermediate destination cities 
# 3 Easy to remember methods\n**Method 1: Intuitive**\nStep 1: Let\'s keep a track of unique entries in source cities (*cityA*) and the intermediate destination cities (*cityB*).\nStep 2: find the missing destination city of *cityB* in source city *cityA*, and that will be our final destination.\n\n```\nclass Solution {\npublic:\n    string destCity(vector<vector<string>>& paths) {\n        unordered_map<string,int> mp;\n        \n        for(size_t i = 0; i<paths.size(); i++)\n        {\n            mp[paths[i][0]] = 1;\n            mp[paths[i][1]]--;\n        }\n        \n        for(auto it = begin(mp); it != end(mp); ++it){\n            if(it->second == -1) return it->first;\n        }\n        \n        return "";\n    }\n};\n```\n\n---\n**Method 2: similar but fast**\nLets modify this process to speed it up with similar concept. But this time we use a map.\nStep 1: Why don\'t we count the entries.\nIf we encounter the city in source *cityA*, then we increment it\'s count by 1.\nWhen we encounter the city in intermediate destination *cityB*, then we decrease it\'s count by 1.\n\nStep 2: Finally if any city has a count of -1, that is our final destination city. This is our answer.\n\n```\nclass Solution {\npublic:\n    string destCity(vector<vector<string>>& paths) {\n        unordered_map<string,int> mp;\n        \n        for(size_t i = 0; i<paths.size(); i++)\n        {\n            mp[paths[i][0]] = 1;\n            mp[paths[i][1]]--;\n        }\n        \n        for(auto it = begin(mp); it != end(mp); ++it){\n            if(it->second == -1) return it->first;\n        }\n        \n        return "";\n    }\n};\n```\n\n---\n\n**Method 3: faster**\nEqually fast or a bit faster than method 2.\n\nLet\'s see this case:\n`A -> B -> C -> D `\nWe don\'t really care about the initial origin source city `A`. We\'re only concered with the destinations.\nSo let\'s fill destinations in a set, and remove the source cities from that set.\nFinally only final answer will remain in our set which we can return.\n\n*p.s. when we encounter a city with no entry in the set (for city `A`), we won\'t see an error as such.*\n\n```\nclass Solution {\npublic:\n    string destCity(vector<vector<string>>& paths) {\n        unordered_set<string> city;\n        \n        for(auto& path: paths) city.insert(path[1]);\n        for(auto& path: paths) city.erase(path[0]);\n        \n        return *begin(city);\n    }\n};\n```\n\nI hope this was helpful. Happy coding \u270C\uFE0F
['C', 'C++']