Skip to content

Commit 8abf1d4

Browse files
authored
Create 1436. Destination City
1 parent 96a7a93 commit 8abf1d4

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

1436. Destination City

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

0 commit comments

Comments
 (0)