Problem of the day

Login

New update is available. Click here to update.

Back to home

Graphs

Problem

Submissions

Solution

New

Discuss

Suggest Edit

Detailed explanation ( Input/output format, Notes, Images )

```
The first line of input contains two integers 'E' and 'V', separated by a single space. They denote the total number of edges and vertices respectively.
From the second line onwards, the next 'V' lines represent an edge between the two vertices.
Every edge is represented by two vertices(u, v) that share an edge between them. The values of the vertices would again be separated by a single space.
```

```
The only line of output prints 'True' if the given graph is a tree, otherwise print 'False'.
```

```
1 < 'V' <= 10^5
0 <= 'E' <= min(10^5, V*(V-1)/2)
0 <= u, v <= V-1
Time Limit: 1 sec
```

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

```
True
```

```
We clearly can see that it is a tree since it satisfies the property of a tree.
```

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

```
False
```

```
As we can see that it is not a tree since it doesn't satisfy the property of a tree.
```

Auto

Console

View hints

Seems like, you got stuck. Refer hints to get directions.

Change Theme

Full Screen Mode

Autocomplete is inactive

Solution submission not allowed

Reset Code