Company: AT&T_6march
Difficulty: medium
There is a tree with tree_nodes nodes numbered from 0 to tree_nodes - 1 . The distance between two nodes is the number of edges in the unique path between them. A node is considered "special" if its distances to three specific nodes x , y , and z , when sorted in ascending order, form a Pythagorean triple ( a , b , c ) where a 2 + b 2 = c 2 . Example tree_nodes = 10 tree_edges = 9 tree_from = [0, 0, 1, 1, 3, 3, 5, 7, 8] tree_to = [4, 1, 2, 3, 5, 7, 6, 8, 9] x = 4, y = 6, and z = 9 Each tree_from[i] is connected to tree_to[i] with a bidirectional edge. Only node 2 forms a Pythagorean triple: Distance from node 2 to node 4 is 3 Distance from node 2 to node 6 is 4 Distance from node 2 to node 9 is 5 The triple (3, 4, 5) is a Pythagorean triple. The answer is 1. Function Description Complete the function countPythagoreanTriples in the editor with the following parameters: int tree_nodes : the number of nodes int tree_from[n] : one end of edge i int tree_to[n] : the other end of edge i int