Learn
Practice
Interview
Resources
Newsletter
F
Toggle theme
0
F
0
Toggle menu
Animations
← Back to All Animations
924. Minimize Malware Spread
Bookmark
Brute Force
Components DFS
Union Find
Input
Example 1
Example 2
Example 3
Two Components
Different Sizes
6 Nodes
Custom
graph
=
[[1,1,0],[1,1,0],[0,0,1]]
,
initial
=
[0,1]
Network
0
1
2
Spread Queue
empty
Infected After Removal
Network
0
1
2
Spread Queue
empty
Infected After Removal
Network
0
removed
1
2
Remove 0 from the infected list and replay the spread
Spread Queue
empty
Infected After Removal
remove 0
?
remove 1
?
Network
0
removed
1
2
Spreading from node 1
Spread Queue
1
Infected After Removal
remove 0
?
remove 1
?
Network
0
removed
1
2
1 and 2 are not connected
Spread Queue
1
0
Infected After Removal
remove 0
?
remove 1
?
Network
0
removed
1
2
0 and 2 are not connected
Spread Queue
1
0
Infected After Removal
remove 0
?
remove 1
?
Network
0
1
removed
2
Remove 1 from the infected list and replay the spread
Spread Queue
empty
Infected After Removal
remove 0
2
remove 1
?
Network
0
1
removed
2
Remove 1 from the infected list and replay the spread
Spread Queue
0
Infected After Removal
remove 0
2
remove 1
?
Network
0
1
removed
2
0 and 1 are connected
Spread Queue
0
Infected After Removal
remove 0
2
remove 1
?
Network
0
1
removed
2
1 and 0 are connected
Spread Queue
0
1
Infected After Removal
remove 0
2
remove 1
?
Network
0
removed
1
2
Remove node 0: 2 node(s) still get infected
Spread Queue
empty
Infected After Removal
remove 0
2
remove 1
2
algo
master
.
io
Step:
A network of 3 nodes with 2 infected. Simulate the spread once per removal candidate.
0 / 35
Input
Example 1
Example 2
Example 3
Two Components
Different Sizes
6 Nodes
Custom
graph
=
[[1,1,0],[1,1,0],[0,0,1]]
,
initial
=
[0,1]
0 / 35
algo
master
.
io
Step:
A network of 3 nodes with 2 infected. Simulate the spread once per removal candidate.