Error
|
|
---|---|
@Ibrahim Nash | 6379 |
@blackshadows | 6329 |
@mb1973 | 5358 |
@Quandray | 5231 |
@akhayrutdinov | 5111 |
@saiujwal13083 | 4510 |
@sanjay05 | 3762 |
@marius_valentin_dragoi | 3522 |
@sushant_a | 3459 |
@verma_ji | 3357 |
@KshamaGupta | 3318 |
Complete Leaderboard | |
|
|
@ritiksethi21 | 1050 |
@aroranayan999 | 807 |
@RizulBansal | 685 |
@ashishtrehan002 | 538 |
@hemantgarg923 | 528 |
@simrangoyal | 526 |
@ronaldo77 | 520 |
@anishrajan | 505 |
@thanosagain | 505 |
@ssparteek470 | 495 |
@rahul2312 | 491 |
Complete Leaderboard |
Given an adjacency list of a graph adj of V no. of vertices having 0 based index. Check whether the graph is bipartite or not.
Example 1:
Input:
Output: 1
Explanation: The given graph can be colored
in two colors so, it is a bipartite graph.
Example 2:
Input:
Output: 0
Explanation: The given graph cannot be colored
in two colors such that color of adjacent
vertices differs.
Your Task:
You don't need to read or print anything. Your task is to complete the function isBipartite() which takes V denoting no. of vertices and adj denoting adjacency list of graph and returns a boolean value true if graph is bipartite otherwise returns false.
Expected Time Complexity: O(V)
Expected Space Complexity: O(V)
Constraints:
1 ≤ V, E ≤ 105
We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?
Yes