Get Node To Remove
Problem Overview
- Remove exactly one node to minimize infections after malware fully spreads; break ties by lowest index.
- Input: g_nodes, edges via g_from/g_to (bidirectional), malware array (1 infected, 0 clean). Output: index to remove.
- Constraints: up to 10^3 nodes, <= min(n(n-1)/2, 10^3) edges, nodes 1..n, malware in {0,1}.
- Context: prototype service for malware control in a server network.
- From Salesforce interviews; a coding interview problem and interview question on network spread.
Example
Unlock to view complete problem details
and practice with sample input/output
Was this article helpful?
View Test Cases & Run Code requires membership
Input Variables
Execution Result:
