We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 0407054 commit 574f279Copy full SHA for 574f279
May-LeetCoding-Challenge/27-Possible-Bipartition/Possible-Bipartition.cpp
@@ -4,16 +4,16 @@ class Solution {
4
vector<vector<int>> G;
5
6
bool bipartite(int u) {
7
- for (int i = 0; i < G[u].size(); i++) {
8
- int v = G[u][i];
9
- if (color[v] == color[u]) return false;
10
- if (!color[v]) {
11
- color[v] = 3 - color[u];
12
- if (!bipartite(v)) return false;
13
- }
14
15
- return true;
16
-}
+ for (int i = 0; i < G[u].size(); i++) {
+ int v = G[u][i];
+ if (color[v] == color[u]) return false;
+ if (!color[v]) {
+ color[v] = 3 - color[u];
+ if (!bipartite(v)) return false;
+ }
+ return true;
17
18
bool possibleBipartition(int N, vector<vector<int>>& dislikes) {
19
color.resize(N+1);
0 commit comments