Skip to content
DeepForgeby svx
All problems
HardGraph Algorithmsgraph-268

Influence Blocking Lite

Problem

Simulate one step of influence spread with a blocked set that cannot be activated.

Seeds try to activate all their neighbors, except seeds themselves, already-active nodes, and blocked nodes. Blocked nodes also cannot spread. Return the sorted list of newly activated nodes. edges is a list of [u, v] pairs.

Hint

Blocking high-degree intermediaries halts cascades at their source.

Test cases

case 1
in: [5,[[0,1],[1,2],[2,3],[3,4]],[0],[1]]
expected: []
case 2
in: [4,[[0,1],[0,2],[0,3],[2,3]],[1],[]]
expected: [0]
case 3
in: [5,[[0,1],[1,2],[2,3],[3,4]],[0,2],[1]]
expected: [3]
Starter codePython
def influence_blocking(n, edges, seeds, blocked):
    # Your code here
    pass

3 test cases · run your code against them in the editor