Algorithm · OpenAI · Medium
Problem You are given an undirected graph representing a network of n nodes labeled 0 to n-1. A set of nodes are initially infected. Every minute, all currently infected nodes simultaneously infect all of their uninfected neighbors. Return the minimum number of minutes required to infect every node in the graph. If some nodes can never be infected (because they are disconnected from any infection source), return -1. Function Signature n: total number of nodes. edges: list of…
Checking your access…