package leetcode;

import java.util.Arrays;
import java.util.List;

/**
 * https://leetcode.com/problems/destination-city/
 */
public class Problem1436 {
    public String destCity(List<List<String>> paths) {
        // TODO
        return null;
    }

    public static void main(String[] args) {
        Problem1436 prob = new Problem1436();
        System.out.println(prob.destCity(Arrays.asList(
            Arrays.asList("London","New York"),
            Arrays.asList("New York","Lima"),
            Arrays.asList("Lima","Sao Paulo")
        ))); // "Sao Paulo"
        System.out.println(prob.destCity(Arrays.asList(
            Arrays.asList("B","C"),
            Arrays.asList("D","B"),
            Arrays.asList("C","A")
        ))); // "A"
        System.out.println(prob.destCity(Arrays.asList(
            Arrays.asList("A","Z")
        ))); // "Z"
    }
}

@@ -54,19 +54,115 @@
 va.util.
-Lis
+HashMap;%0Aimport java.util.HashSet;%0Aimport java.util.List;%0Aimport java.util.Map;%0Aimport java.util.Se
 t;%0A%0A/**%0A
@@ -310,652 +310,481 @@
     
-// TODO%0A        return null;%0A    %7D%0A%0A    public static void main(String%5B%5D args) %7B%0A        Problem1436 prob = new Problem1436();%0A        System.out.println(prob.destCity(Arrays.asList(%0A            Arrays.asList(%22London%22,%22New York%22),%0A            Arrays.asList(%22New York%22,%22Lima%22),%0A            Arrays.asList(%22Lima%22,%22Sao Paulo%22)%0A        ))); // %22Sao Paulo%22%0A        System.out.println(prob.destCity(Arrays.asList(%0A            Arrays.asList(%22B%22,%22C%22),%0A            Arrays.asList(%22D%22,%22B%22),%0A            Arrays.asList(%22C%22,%22A%22)%0A        ))); // %22A%22%0A        System.out.println(prob.destCity(Arrays.asList(%0A            Arrays.asList(%22A%22,%22Z%22)%0A        ))); // %22Z%22
+Map%3CString, String%3E map = new HashMap%3C%3E();%0A        Set%3CString%3E destinations = new HashSet%3C%3E();%0A        for (List%3CString%3E path : paths) %7B%0A            map.put(path.get(0), path.get(1));%0A            destinations.add(path.get(1));%0A        %7D%0A        String answer = null;%0A        for (String destination : destinations) %7B%0A            if (!map.containsKey(destination)) %7B%0A                answer = destination;%0A                break;%0A            %7D%0A        %7D%0A        return answer;
 %0A   

Solve problem 1436