You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
java.lang.NullPointerException: Cannot invoke "java.util.List.iterator()" because the return value of "java.util.Map.get(Object)" is null
at line 6, Solution.isBipartite
at line 79, Solution.magnificentSets
which is caused by by
adj.computeIfAbsent(u, k -> new ArrayList<>()).add(v);
adj.computeIfAbsent(v, k -> new ArrayList<>()).add(u);
can be resolved by
adj.get(u).add(v);
adj.get(v).add(u);
This occurs because some nodes in the graph may not have any neighboring nodes, which can lead to null pointer exception in isBipartite() method