Company: Intuit_18_jan
Difficulty: medium
Product Dependency Tree Problem 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 . A triplet of nodes (i, j, k) has a simple path connecting them if one of the nodes lies on the unique simple path between the other two. Your goal is to count the triplets that are "non-collinear". 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. Exa