Company: Amazon_14oct
Difficulty: medium
Collect The Coins Problem Description Alex is playing a game in Hackerland. The city is a tree with tree_nodes vertices labeled 0 to tree_nodes - 1 . An array coins of size tree_nodes tells which vertices hold a coin: coins[i] is 1 if vertex i holds a coin and 0 otherwise. The distance between two vertices is the number of edges on the unique path between them. Standing at a vertex x , Alex collects every coin that lies at distance at most 2 from x (this includes a coin at x itself, at a neighbour of x , and at a neighbour of a neighbour). Alex picks any starting vertex, walks along edges, and must finish at the vertex he started from. An edge may be traversed any number of times, and all edges are bidirectional. A coin is collected as soon as Alex stands at some vertex within distance 2 of it. Find the smallest number of edge traversals in such a closed walk that collects every coin. Complete the function getMinPath with the following parameters: coins : array of tree_nodes integers,