Company: Amazon_14oct
Difficulty: medium
Collect The Coins Problem Description Alex is playing a game in Hackerland and needs to collect coins from various locations. The city is represented as 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, where 1 means the vertex contains a coin. Alex must travel 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, but must start and end at that 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. The function is expected to return an INTEGER . The function accepts the following parameters: int getMinPath(vector coins, int t