(node: int, color: int, graph: List[List[int]], colors: List[int])
| 10 | return True |
| 11 | |
| 12 | def dfs(node: int, color: int, graph: List[List[int]], colors: List[int]) -> bool: |
| 13 | colors[node] = color |
| 14 | for neighbor in graph[node]: |
| 15 | # If the current neighbor has the same color as the current |
| 16 | # node, the graph is not bipartite. |
| 17 | if colors[neighbor] == color: |
| 18 | return False |
| 19 | # If the current neighbor is not colored, color it with the |
| 20 | # other color and continue the DFS. |
| 21 | if colors[neighbor] == 0 and not dfs(neighbor, -color, graph, colors): |
| 22 | return False |
| 23 | return True |
no outgoing calls
no test coverage detected