Bipartite Graph Check

this is the same code that prateek sir had coded.
code: https://ide.codingblocks.com/s/439687

but this is not accepted code for leetcode problem:https://leetcode.com/problems/is-graph-bipartite/

hello @aman17nov1999

graph may be disonnected , u need to run ur dfs helper function for every component

code is not working for this test case also: [[4,1],[0,2],[1,3],[2,4],[3,0]]

what those pairs are indicating?
[4,1] by this do u want to indicate that there is edge between 4 and 1?

yes,it indicates that there is edge between 4 and 1

that is issue.
in input u need to feed adjacency list
for example->
0-> [ 2,3,4,5]
1->[0,3]
2->[0,1,4]

then in input u need to give
[[2,3,4,5],[0,3],[0,2,4]]

Sorry sir, [1,4] doesnt indicate edge between 1 and 4.
It indicates that nbrs of 0 are 1 and 4.

chekc now->

memset was not working correcly over leetcode, so use loop to initialise ur visited array with 0

Yes, it got accepted now. But how do get to know that memset is not working fine…

i just tried printing its values. it was showing garbage result even after initilaisation

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.