Destination City LeetCode solution in JavaScript

1
/*
2
* @param {string[][]} paths
3
* @return {string}
4
*/
5
var destCity = function (paths) {
6
let map = {};
7

8
for (let city of paths) {
9
map[city[0]] = map[city[0]] ? map[city[0]] + 1 : 1;
10
}
11

12
for (let city of paths) {
13
if (!map[city[1]]) return city[1];
14
}
15
};

0

WPM •0 •0

100%

ACC •0 •0

0s

TIME •0