New update is available. Click here to update.

Last Updated: 7 Jul, 2016

Difficulty: Moderate

```
The given graph may have connected components.
```

```
The first line of input contains two integers 'V' and 'E', separated by a single space. They denote the total number of vertices and edges respectively.
From the second line onwards, the next 'E' 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.
```

```
Print "YES" if it is possible else print "NO".
```

```
1 <= E <= 10 ^ 5
1 <= V <= 10 ^ 6
Time Limit: 1 sec
```

SIMILAR PROBLEMS

Plantation

Posted: 9 Sep, 2022

Difficulty: Moderate

COUNT ISLANDS

Posted: 14 Sep, 2022

Difficulty: Moderate

Capturing Grid

Posted: 14 Sep, 2022

Difficulty: Moderate

Rotting Oranges

Posted: 15 Sep, 2022

Difficulty: Moderate

Distance to a Cycle in Undirected Graph

Posted: 7 Nov, 2022

Difficulty: Moderate

Popular Interview Problems: