JavaScript
- 1 ответ
- 0 вопросов
1
Вклад в тег
val tickets = [ ... ... ... ]
val from = new hash_map()
val to = new hash_map()
for (t in tickets) {
from[t.from] = t
to[t.to] = t
}
val begin = null;
for (t in tickets) {
if (to[t.from] == null) {
begin = t
break
}
}
tickets[0] = begin
for (i in range 1..tickets.length-1) {
tickets[i] = from[tickets[i-1].to]
}