Company: Mathworks_26oct
Difficulty: medium
Cool Graph Problem Description You are given an undirected connected graph with g_nodes nodes, numbered 1 to g_nodes , and M edges. The i -th edge joins g_from[i] and g_to[i] . A traversal starts at any node and repeatedly moves along an edge to a neighbouring node. Nodes may be visited more than once. Record the visited nodes, in order, in an array A , and keep walking until every node has been visited at least once. Array B is built from A with the following procedure: for (int i = 0; i < A.size(); i++) { bool found = 0; for (int j = 0; j < B.size(); j++) { if (A[i] == B[j]) { found = 1; break; } } if (!found) { B.push_back(A[i]); } } In other words, B lists the nodes of A in the order of their first appearance. Choose the traversal A so that B is the lexicographically largest array possible, and return that B . Function Description Complete the function coolGraph in the editor. It has the following parameters: g_nodes : the number of nodes g_from : one end of each edge g_to :