Destination City LeetCode solution in Java
1class Solution {2public String destCity(List<List<String>> paths) {3HashSet<String> set1 = new HashSet<>();45for (int i = 0; i < paths.size(); ++i) {6set1.add(paths.get(i).get(0));7}8for (int i = 0; i < paths.size(); ++i) {9if (!set1.contains(paths.get(i).get(1))) return paths.get(i).get(1);10}11return "placeholder";12}13}