File tree Expand file tree Collapse file tree 2 files changed +4
-4
lines changed
0924-Minimize-Malware-Spread/cpp-0924 Expand file tree Collapse file tree 2 files changed +4
-4
lines changed Original file line number Diff line number Diff line change @@ -32,8 +32,8 @@ class Solution {
32
32
visited.resize (n, false );
33
33
34
34
int best = 0 , res = -1 , ccid = 0 ;
35
- for (int v = 0 ; v < n; v ++ )
36
- if (init_set. count (v) && !visited[v]){
35
+ for (int v: init_set )
36
+ if (!visited[v]){
37
37
cc_sz.push_back (0 ), cc_mal_num.push_back (0 );
38
38
cc_sz[ccid] = dfs (graph, v, ccid);
39
39
if (cc_mal_num[ccid] == 1 && cc_sz[ccid] > best){
@@ -50,6 +50,7 @@ class Solution {
50
50
51
51
visited[v] = true ;
52
52
if (init_set.count (v)) cc_mal_num[ccid] ++;
53
+
53
54
int res = 1 ;
54
55
for (int next = 0 ; next < n; next ++)
55
56
if (g[v][next] && !visited[next])
Original file line number Diff line number Diff line change @@ -67,8 +67,7 @@ class Solution {
67
67
if (graph[i][j])
68
68
uf.unionElements (i, j);
69
69
70
- set<int > init_set;
71
- for (int e: initial) init_set.insert (e);
70
+ set<int > init_set (initial.begin (), initial.end ());
72
71
73
72
unordered_map<int , int > cc_sz, cc_mal_num;
74
73
for (int e: init_set)
You can’t perform that action at this time.
0 commit comments