Easy HashMap iterative approach beginner friendly
Intuition\n Describe your first thoughts on how to solve this problem. \nWe recived input in pairs so it gives us an idea to use hash maps.\n\n# Approach\n Desc
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nWe recived input in pairs so it gives us an idea to use hash maps.\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\nWe just need to store our pairs is key value form in our hash map and their is just one value in our key value pairs in hash map that does not occur in our key set of maps and that is our answer\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\nO(n);\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\nO(n)\n\n# Code\n```\nclass Solution {\n    public String destCity(List<List<String>> paths) {\n        HashMap<String, String> map = new HashMap<>();\n\n        for(int i = 0;i<paths.size();i++) {\n            map.put(paths.get(i).get(0),paths.get(i).get(1));\n        }\n        String ans = "";\n        for(String key : map.keySet()) {\n            String val = map.get(key);\n\n            if(!map.containsKey(val)){\n                ans = val;\n            }\n        }\n\n        return ans;\n    }\n}\n```
['Hash Table', 'Hash Function', 'Java']