package hackerrank;

import java.util.Scanner;

/**
 * https://www.hackerrank.com/challenges/primsmstsub
 */
public class PrimsSpecialSubtree {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        // TODO
    }
}

@@ -14,16 +14,115 @@
 rrank;%0A%0A
+import java.util.ArrayList;%0Aimport java.util.HashMap;%0Aimport java.util.List;%0Aimport java.util.Map;%0A
 import j
@@ -245,108 +245,1254 @@
    p
-ublic static void main(String%5B%5D args) %7B%0A        Scanner in = new Scanner(System.in);%0A        // TODO
+rivate static int mst(Map%3CInteger, List%3CEdge%3E%3E adjList, int start) %7B%0A        // TODO%0A        return 0;%0A    %7D%0A%0A    private static class Edge %7B%0A        private final int v1;%0A        private final int v2;%0A        private final int weight;%0A%0A        public Edge(int v1, int v2, int weight) %7B%0A            this.v1 = v1;%0A            this.v2 = v2;%0A            this.weight = weight;%0A        %7D%0A%0A        public int either(int v) %7B%0A            return v1;%0A        %7D%0A%0A        public int other(int v) %7B%0A            if (v == v1) %7B%0A                return v2;%0A            %7D%0A            return v1;%0A        %7D%0A    %7D%0A%0A    public static void main(String%5B%5D args) %7B%0A        Scanner in = new Scanner(System.in);%0A        int n = in.nextInt();%0A        int m = in.nextInt();%0A        Map%3CInteger, List%3CEdge%3E%3E adjList = new HashMap%3C%3E();%0A        for (int vertex = 0; vertex %3C n; vertex++) %7B%0A            adjList.put(vertex, new ArrayList%3C%3E());%0A        %7D%0A        for (int i = 0; i %3C m; i++) %7B%0A            int x = in.nextInt();%0A            int y = in.nextInt();%0A            int r = in.nextInt();%0A            adjList.get(x).add(new Edge(x, y, r));%0A            adjList.get(y).add(new Edge(x, y, r));%0A        %7D%0A        int s = in.nextInt();%0A        System.out.println(mst(adjList, s));
 %0A   

Update Prim's: Special Subtree