blob: 427d9e27a334a84cdea60b0121a97cbeed9fdef3 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
let routes = [["B","C"], ["D","B"], ["C","A"]];
proc(routes);
routes = [["A","Z"]];
proc(routes);
function proc(routes) {
console.log("Input: ");
for (let j = 0; j < routes.length; j++) {
console.log(routes[j]);
}
let inlist = [];
let outlist = [];
for (let j of routes) {
inlist.push(j[0]);
outlist.push(j[1]);
}
let ans = "a";
for (let needle of outlist) {
let found = 0;
for (let hay of inlist) {
if (needle == hay) {
found = 1;
break;
}
}
if (found == 0) {
ans = needle;
}
}
console.log( "Output:", ans);
}
|