Company: Microsoft_12july
Difficulty: medium
Pythagorean Triple in a Tree Problem Description There is a tree with tree_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 . 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 x : the node associated with value a in the Pythagorean triple int y : the node for value b int z : the node for value c Returns int : the total number of special nodes Examples Example 1: Input: tree_nodes = 10 tree_edges = 9 tree_from = [0, 1, 3, 3, 5, 7, 8] tree_to = [1, 2, 3, 5, 7, 8, 9] x = 4, y = 6, z = 9 Output: 1 Explanation: Each tree_from[i] is connected to tree_to[i] with a bidirectional edge