We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Kruskal (MST): Really Special Subtree
Kruskal (MST): Really Special Subtree
Sort by
recency
|
189 Discussions
|
Please Login in order to post a comment
What is wrong with mys solution - ? public static int kruskals(int gNodes, List gFrom, List gTo, List gWeight) { var edges = new List>(); for (int i = 0; i < gFrom.Count; i++) { edges.Add(new Tuple(gFrom[i], gTo[i], gWeight[i])); }
}
VoIP technology is continuously evolving, with ongoing advancements in features, capabilities, and integration options. Providers are constantly innovating to incorporate emerging technologies such as Artificial Intelligence (AI), machine learning, and advanced analytics into their VoIP systems. This commitment to innovation ensures that VoIP services remain at the forefront of communication technology VoIP Phone Services, offering businesses and individuals access to the latest tools and solutions to stay competitive and adapt to future developments.
C++ (more at https://github.com/IhorVodko/Hackerrank_solutions/tree/master , feel free to give a star:) )
My python solution
include
using namespace std;
string ltrim(const string &); string rtrim(const string &); vector split(const string &);
/* * Complete the 'kruskals' function below. * * The function is expected to return an INTEGER. * The function accepts WEIGHTED_INTEGER_GRAPH g as parameter. */
int findParent(vector& parent, int x) { if (parent[x] == x) return x; return parent[x] = findParent(parent, parent[x]); }
void unionSet(vector& parent, vector& rank, int x, int y) { int rootX = findParent(parent, x); int rootY = findParent(parent, y); if (rootX != rootY) { if (rank[rootX] < rank[rootY]) { parent[rootX] = rootY; } else if (rank[rootX] > rank[rootY]) { parent[rootY] = rootX; } else { parent[rootY] = rootX; rank[rootX]++; } } }
int kruskals(int g_nodes, vector g_from, vector g_to, vector g_weight) { int numEdges = g_from.size(); vector>> edges(numEdges); for (int i = 0; i < numEdges; ++i) { edges[i] = {g_weight[i], {g_from[i], g_to[i]}}; } sort(edges.begin(), edges.end());
}
int main() { ofstream fout(getenv("OUTPUT_PATH"));
}
string ltrim(const string &str) { string s(str);
}
string rtrim(const string &str) { string s(str);
}
vector split(const string &str) { vector tokens;
}