Leetcode - Is Graph Bipartite? (Python)

preview_player
Показать описание
February 2021 Leetcode Challenge
Leetcode - Is Graph Bipartite? #785
Difficulty: Medium
Рекомендации по теме
Комментарии
Автор

That XOR trick is really gold medal to think!

MsSkip
Автор

I guess an alternative way is just to check whether all nodes have been touched at the end by going through col and return False if we find a -1.

hangchen
Автор

It took me a bit to realize that we just traverse the graph checking that edge connects nodes of different colors! And then the edge case of the graph not being connected fully was a wrench! lol Thanks Tim!

janmichaelaustria
Автор

Waiting on the complete explanation that you wanted to do Tim! hope you can find time to do it.

Автор

Have you come across this question before to solve it under 8 minutes?

KarmaRyder
Автор

Can somebody please explaing this part: "
if colors[node] != color:
return False "
in what situation this would be False

yilmazbingol
welcome to shbcf.ru