[JavaScript] 1436. Destination City
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n\n---\n\n```\nvar destCity = function (paths) {\n  const srcSet = new Set()\n  const dests = []\n  for (const [src, dest] of paths) {\n    srcSet.add(src)\n    dests.push(dest)\n  }\n  for (const dest of dests) {\n    if (!srcSet.has(dest)) {\n      return dest\n    }\n  }\n}\n```\n\n---\n\nTests:\n```\n[["London","New York"],["New York","Lima"],["Lima","Sao Paulo"]]\n// "Sao Paulo"\n[["B","C"],["D","B"],["C","A"]]\n// "A"\n[["A","Z"]]\n// "Z"\n```\n\n---\n
['JavaScript']