Hamiltonian Path

0

0 votes
Very-Easy
Problem

Given an undirected graph check whether it contains a Hamiltonian Path or not.

Input:
First line consists of two space separated integers N and M denoting the number of vertices and number of edges.
Following M lines consists of two space separated integers X and Y denoting there is an edge between X and Y.

Output:
Print in a new line "YES" (without quotes) if the graph contains a Hamiltonian Path otherwise print "NO" (without quotes).

Constraints:
1 ≤ N ≤ 10
1 ≤ M ≤ 10
1 ≤ X, YN

Time Limit: 5
Memory Limit: 256
Source Limit:
Editor Image

?