Company: Gameskraft_17_dec
Difficulty: medium
Count Tree Paths Problem Description Given a network of product dependencies represented as a tree. The tree consists of treeNodes vertices, and the relationships between products are defined by two arrays: treeFrom and treeTo , both of size treeNodes - 1 . These arrays specify connections, where treeFrom[i] is connected to treeTo[i] . For this product dependency tree, the task is to determine the number of triplets of vertices (i, j, k) that meet the following conditions: 0 ≤ i < j < k < treeNodes There should be no simple path connecting vertices i, j, and k. Due to the potentially large number of triplets, return the answer modulo (10 9 + 7). Notes A path in this context refers to a sequence of vertices where each vertex is connected to the next one, representing a product dependency relationship. A path that does not include repeated vertices is termed a simple path. Example (from problem description) Given treeNodes = 5 , treeFrom = [1, 1, 0, 0] , treeTo = [0, 2, 3, 4]