Company: Intuit_21_jan
Difficulty: medium
Product Dependency Tree You are 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] . Your 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 refers to a sequence of vertices where each vertex is connected to the next one. A simple path is a path that does not include repeated vertices. Example 1: Input: treeNodes = 5 treeFrom = [1, 1, 0, 0] treeTo = [0, 2, 3, 4] Output: 2 Explanation: The following triplets of vertices lack a simple path connecting them: (1, 3, 4) (2, 3, 4) There are 2 such tri