infected_by
to keep track of the number of nodes that can infect each node.u
in initial
, perform a DFS starting from u
to find all nodes that can be infected by u
.u
and increment the count in infected_by
for each node reached.v
not in initial
, determine if it is uniquely infected by only one node u
in initial
.u
in initial
, calculate the total number of nodes that would be uniquely infected if u
were removed.u
that, if removed, results in the smallest number of total infections. If there are multiple such nodes, return the one with the smallest index.