Company: Infosys
Difficulty: hard
# Maximum Network Engagement Frequency You manage a social network represented by a rooted tree of `N` users. User `1` is the root. User `i` has integer engagement level `value[i]`. Define `EngTotal(i)` as the sum of engagement levels in the subtree rooted at user `i`, including user `i`. The engagement frequency of a number is the number of users whose `EngTotal` equals that number. You may choose one user and replace that user's engagement level by any integer, including its current value. Find the maximum possible frequency of a single `EngTotal` value after the replacement. ## Input Format - The first line contains `N`. - The second line contains `N` integers `parent[1] ... parent[N]`, where `parent[1] = 0` and `parent[i]` is the parent of user `i` for `i > 1`. - The third line contains `N` integers `value[1] ... value[N]`. ## Output Format Print the maximum achievable engagement frequency. ## Constraints - `1 <= N <= 200000` - `parent[1] = 0` - The parent array descri