package leetcode;

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

/**
 * https://leetcode.com/problems/minimum-number-of-vertices-to-reach-all-nodes/
 */
public class Problem1557 {
    public List<Integer> findSmallestSetOfVertices(int n, List<List<Integer>> edges) {
        // TODO
        return null;
    }

    public static void main(String[] args) {
        Problem1557 prob = new Problem1557();
        System.out.println(prob.findSmallestSetOfVertices(6, Arrays.asList(
            Arrays.asList(0, 1),
            Arrays.asList(0, 2),
            Arrays.asList(2, 5),
            Arrays.asList(3, 4),
            Arrays.asList(4, 2)
        ))); // [0,3]
        System.out.println(prob.findSmallestSetOfVertices(5, Arrays.asList(
            Arrays.asList(0, 1),
            Arrays.asList(2, 1),
            Arrays.asList(3, 1),
            Arrays.asList(1, 4),
            Arrays.asList(2, 4)
        ))); // [0,2,3]
    }
}

@@ -34,17 +34,71 @@
 il.Array
-s
+List;%0Aimport java.util.Arrays;%0Aimport java.util.HashSet
 ;%0Aimport
@@ -113,16 +113,38 @@
 il.List;
+%0Aimport java.util.Set;
 %0A%0A/**%0A *
@@ -351,660 +351,332 @@
     
-// TODO%0A        return null;%0A    %7D%0A%0A    public static void main(String%5B%5D args) %7B%0A        Problem1557 prob = new Problem1557();%0A        System.out.println(prob.findSmallestSetOfVertices(6, Arrays.asList(%0A            Arrays.asList(0, 1),%0A            Arrays.asList(0, 2),%0A            Arrays.asList(2, 5),%0A            Arrays.asList(3, 4),%0A            Arrays.asList(4, 2)%0A        ))); // %5B0,3%5D%0A        System.out.println(prob.findSmallestSetOfVertices(5, Arrays.asList(%0A            Arrays.asList(0, 1),%0A            Arrays.asList(2, 1),%0A            Arrays.asList(3, 1),%0A            Arrays.asList(1, 4),%0A            Arrays.asList(2, 4)%0A        ))); // %5B0,2,3%5D
+Set%3CInteger%3E set = new HashSet%3C%3E();%0A        for (List%3CInteger%3E edge : edges) %7B%0A            set.add(edge.get(1));%0A        %7D%0A        List%3CInteger%3E answer = new ArrayList%3C%3E();%0A        for (int i = 0; i %3C n; i++) %7B%0A            if (!set.contains(i)) %7B%0A                answer.add(i);%0A            %7D%0A        %7D%0A        return answer;
 %0A   

Solve problem 1557