
The first line contains four integers 'n', 'm', 's', and 'k' where 'n' is the number of vertices, 'm' is the no of edges, and 's' is the source vertex.
The next 'm' lines describe the edge. Each edge is characterized by three integers a, b, and c where a and b denote the endpoints of the edge and c the length of the edge.
The edges[i][0] ,edges[i][1] contains the vertex that is connected to the edge. The edges[i][2] contains the length of edge for all 0<i<m.
Return true if there is any such path otherwise false.
Graph does not contain self-loops.
1 <= 'n' <= 10
1 <= 'm' <= min(n*(n-1))/2,100)
0 <= 'a', 'b', 's' <= n-1
1 <= ci, k <= 1000000
For all 1 <= i <= m
Time Limit: 1 sec
The key idea will be to find all possible paths and check their path length. If the path length is greater than ‘k’ we return true. If no path has a weight greater than ‘k’ we return false.
The algorithm is as follows:
From the source vertex all the paths and check if the total distance is greater than ‘k’.