Company: Humming_Bird_21_jan
Difficulty: medium
Hamilton path A Hamilton path is a path in an undirected graph that visits each vertex exactly once. Given an undirected graph, the task is to check if a Hamilton path is in it or not. Input Format The first line consists of two space separated integers N and M denoting the number of vertices and number of edges. Then in the next M lines are 2 space separated integers u , v denoting an undirected edge between u and v . Output Format Return true if the graph contains a Hamilton path, otherwise return false . Note: In the examples, 1 is used for true and 0 for false. Examples Example 1 Input: 4 3 1 2 2 3 2 4 Output: 0 Explanation: It can be proved that there is no hamilton path in the graph. Example 2 Input: 4 4 1 2 2 3 3 4 2 4 Output: 1 Explanation: The graph is: 1----2----3 | | |----4 The Hamilton path is 1-2-3-4. Constraints 1 <= N <= 10 1 <= M <= 15 1 <= value of each node <= N Solution import java.io.*; import java.util.*; class Main { public static void main(Strin