diff --git a/solution/3300-3399/3378.Count Connected Components in LCM Graph/Solution1.cpp b/solution/3300-3399/3378.Count Connected Components in LCM Graph/Solution1.cpp index 8436808daadc2..9d91022a2731d 100644 --- a/solution/3300-3399/3378.Count Connected Components in LCM Graph/Solution1.cpp +++ b/solution/3300-3399/3378.Count Connected Components in LCM Graph/Solution1.cpp @@ -32,15 +32,15 @@ typedef struct DSU { class Solution { public: - int countComponents(vector &nums, int threshold) { + int countComponents(vector& nums, int threshold) { DSU dsu(threshold); - for (auto &num : nums) { + for (auto& num : nums) { for (int j = num; j <= threshold; j += num) { dsu.unionSet(num, j); } } unordered_set par; - for (auto &num : nums) { + for (auto& num : nums) { if (num > threshold) { par.insert(num); } else { diff --git a/solution/3300-3399/3378.Count Connected Components in LCM Graph/Solution2.cpp b/solution/3300-3399/3378.Count Connected Components in LCM Graph/Solution2.cpp index e398b903a990c..95af4408b0a58 100644 --- a/solution/3300-3399/3378.Count Connected Components in LCM Graph/Solution2.cpp +++ b/solution/3300-3399/3378.Count Connected Components in LCM Graph/Solution2.cpp @@ -1,19 +1,19 @@ class Solution { private: - void dfs(int node, vector> &adj, vector &vis) { + void dfs(int node, vector>& adj, vector& vis) { if (vis[node]) return; vis[node] = true; - for (auto &u : adj[node]) { + for (auto& u : adj[node]) { dfs(u, adj, vis); } } public: - int countComponents(vector &nums, int threshold) { + int countComponents(vector& nums, int threshold) { vector> adj(threshold + 1); vector vis(threshold + 1, false); int ans = 0; - for (auto &num : nums) { + for (auto& num : nums) { if (num > threshold) { ++ans; continue; @@ -23,7 +23,7 @@ class Solution { adj[j].push_back(num); } } - for (auto &num : nums) { + for (auto& num : nums) { if (num <= threshold && !vis[num]) { dfs(num, adj, vis); ++ans;