Company: Zomato
Difficulty: medium
Count Tree Paths 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 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. Input Format The first line contains two space-separated integers, treeNodes and treeEdges (where treeEdges = treeNodes - 1 ), representing the number of n