Skip to content

Commit b8813a8

Browse files
Create 1436. Destination City.cpp
1 parent 73e9fb8 commit b8813a8

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

1436. Destination City.cpp

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
class Solution {
2+
public:
3+
string destCity(vector<vector<string>>& paths) {
4+
5+
int n = paths.size();
6+
unordered_map<string,int>mp;
7+
8+
for(int i = 0 ; i < n ; i++){
9+
mp[paths[i][0]]++;
10+
}
11+
12+
string ans = "";
13+
for(int i = 0 ; i < n; i++){
14+
if(mp.find(paths[i][1]) == mp.end()){
15+
ans = paths[i][1];
16+
break;
17+
}
18+
}
19+
return ans;
20+
}
21+
};

0 commit comments

Comments
 (0)