Company: Cisco_31_jan
Difficulty: medium
Collect The Coins Description Alex is playing a game in Hackerkland and needs to collect coins from various locations. The city is represented by a tree with n vertices labeled from 0 to n - 1 . There is an array called coins of size n , where coins[i] is either 0 or 1 . A value of 1 means the vertex i contains a coin. Alex must travel along the tree's edges to collect all the coins. The distance between two vertices is the number of edges between them. From any given vertex x , Alex can collect all coins located within a distance of 2 edges from x . The goal is to find the shortest path that allows Alex to collect all the coins. Alex can choose any vertex to start, but must end at that same starting vertex. The path can traverse the same edge multiple times, and all edges are bidirectional. Return the number of edges in the shortest path along which Alex can collect all the coins. Example Given the following tree and coin distribution: tree_nodes = 11 tree_from = [0, 0, 0, 1, 1, 3, 4,