{"ScriptPreparationCode":null,"TestCases":[{"Name":"test - alex","Code":"const foo=(tickets)=\u003Etickets.sort((a, b)=\u003E{\r\n if(a.to === b.from) return -1;\r\n if(b.to === a.from) return 1;\r\n return 0;\r\n});\r\nfoo([\r\n { from: \u0027London\u0027, to: \u0027Moscow\u0027 },\r\n { from: \u0027NY\u0027, to: \u0027London\u0027 },\r\n { from: \u0027Moscow\u0027, to: \u0027SPb\u0027 },\r\n]);","IsDeferred":false},{"Name":"test - kirill","Code":"function findShortPath(tickets){\r\n \r\n const result = [];\r\n \r\n const mapOfTo = {};\r\n const mapOfFrom = {};\r\n \r\n tickets.forEach(ticket =\u003E {\r\n mapOfTo[ticket[\u0027to\u0027]] = true;\r\n mapOfFrom[ticket[\u0027from\u0027]] = ticket;\r\n });\r\n \r\n let start = tickets.find(ticket =\u003E !mapOfTo.hasOwnProperty(ticket[\u0027from\u0027])).from;\r\n \tlet foundTicket\r\n \r\n while(foundTicket = mapOfFrom[start]){\r\n result.push(foundTicket);\r\n start = foundTicket[\u0027to\u0027];\r\n }\r\n \r\n return result;\r\n}\r\nfindShortPath([\r\n { from: \u0027London\u0027, to: \u0027Moscow\u0027 },\r\n { from: \u0027NY\u0027, to: \u0027London\u0027 },\r\n { from: \u0027Moscow\u0027, to: \u0027SPb\u0027 },\r\n]);","IsDeferred":false}]}