Get Minimum Servers
In a neural network, there are nodes representing servers capturing neural signals in a cutting-edge machine learning application. Akin to the architecture of a neural network, there are server_nodes servers, where the ith server captures the signal of minimum neural activity represented by minActivity[i]. The servers are connected in a tree structure with server_nodes - 1 connections, where the ith connection connects the servers server_from[i] and server_to[i] and the change in neural activity of the signal traveling the ith connection is represented by server_weight[i].
The neural activity of a signal transmitted from server x and reaching server y is the sum of the neural activity change by traveling across the path from x to y.
Note:
server_weight[i] is positive or negative respectively.
A server u is said to be vulnerable if there exists a server v (!= u) in the subtree of u such that:
v from server u is greater than minActivity[v].
Note: A subtree of a node x is a tree containing all the children of x and having x as the root.
The server can be disconnected in the following way:
The task is to determine the minimum number of servers that need to be disconnected such that no server remains vulnerable.
Complete the function getMinServers in the editor.
getMinServers has the following parameters:
int server_nodes: the number of serversvector: the server from which the signal is sentserver_from vector: the server to which the signal is sentserver_to vector: the change in neural activity due to the signal passing through the serverserver_weight vector: the minimum neural activity that a server can handle without being vulnerableminActivity
Returns
int: the minimum number of servers that need to be disconnected
1Example 1

2Example 2
Constraints
Limits and guarantees your solution can rely on.