Company: Salesforce_12nov
Difficulty: medium
Key Salesforce Teams Problem Description In a Salesforce organizational hierarchy, the structure is represented as a tree with N nodes, each corresponding to a team. A team is called 'key team' if it is an endpoint of any of the longest communication paths (diameters) within the hierarchy. For all the teams in the hierarchy, determine if they are key teams or not. Thus, return a binary array, where the Pth value of the array will be 1, if the Pth node is a key team. Else, the Pth value of the array will be 0. Note: The diameter of a tree is defined as the number of edges in the longest path of the tree. For example, consider a tree with nodes 1, 2, 3 and edges (1,2), (2,3). We can see that this tree has only one diameter, which is the unique path between nodes 1 and 3. The length of the diameter is 2. The end-points of the diameter are 1 and 3. Hence, nodes 1 and 3 are considered key teams, while node 2 is not considered a key team of the tree. Complete the function `isKeyTeam` in the