Login

All Problems

Problem title

Difficulty

Avg time to solve

Patternify

Easy

--

Minimum Jumps

Moderate

25 mins

Sum root to leaf

Easy

10 mins

Bipartite Graph

Moderate

50 mins

Maximum subarray

Moderate

55 mins

Container With Most Water

Moderate

15 mins

Encode the Message

Easy

18 mins

Max Game

Easy

25 mins

Chess Tournament

Easy

20 mins

N Queens

Hard

55 mins

Problem

Submissions

24

Avg. time to solve

50 min

Success Rate

50%

Problem Statement

```
If edges[i][j] = 1, that implies there is a bi-directional edge between ‘i’ and ‘j’, that means there exists both edges from ‘i’ to ‘j’ and to ‘j’ to ‘i’.
```

```
Given:
‘N’ = 3
‘edges’ = [[0, 1, 1], [0, 0, 1], [0,0,0]].
```

```
The first line of input contains an integer ‘T’ denoting the number of test cases.
The first line of each test case contains two space-separated integers, ‘N,’ where ‘N’ is the number of rows in ‘edges’ and the number of columns in ‘edges’.
The next ‘N’ line of each test case contains ‘N’ space-separated integers which tell if there is an edge between ‘i’ and ‘j’.
```

```
For each test case, You are supposed to return a bool value determining whether the graph is bipartite or not.
```

```
You are not required to print the expected output; it has already been taken care of. Just implement the function.
```

```
1 <= ‘T’ <= 10
2 <= ‘N’ <= 300
0 <= ‘edges[i][j]’ <= 1.
Time Limit: 1sec.
```

```
2
4
0 1 0 0
0 0 0 1
0 0 0 0
0 0 0 0
3
0 1 1
0 0 1
0 0 0
```

```
1
0
```

```
In the first test case, the graph is visualized as below,
```

```
The graph can be divided into 2 disjointed sections, i.e. S1 = {0,2} and S2 = {1,3}. Therefore the answer is true.
In the second test case, the graph is visualized as below:
```

```
The answer is 0 since there is no way this graph can be divided into 2 disjoint sets of points.
```

```
2
4
0 0 1 0
0 0 0 1
0 0 0 0
0 0 0 0
3
0 1 1
0 0 0
0 0 0
```

```
1
1
```

Console

Sample Test Case

Custom Test Case

Download Test Cases

Test Case 1

Test Case 2

Test Case 3

Saving Code...

Full Screen Mode

Change Language

Change Theme

Solution submission not allowed

Save Code

Reset Code