
Assume that the source vertex to always be 0.
Here 'V' = 9, 'E' = 14 and 'K' = 60

Output: YES
Explanation:
There exists a simple path 0 -> 7 -> 1-> 2 -> 3 -> 4 -> 5-> 6 -> 8
Which has a total distance of 61 units which is more than 60.
The first line contains space-separated integers 'V', ’E’ and ‘K’ where ‘V’ is the number of vertices in the graph, ‘E’ the number of edges while ‘K’ denotes the sum of the weights in the simple path which should be greater than ‘K’
Then ‘E’ lines follow. Each line contains 3 space-separated integers denoting the values where the first value is vertex V1, next is vertex V2 and the last value is the weight (W) of the edge between vertices V1 and V2, respectively.
For the given graph, set of edges, vertices, and value ‘K’, return ‘YES’ if there exists a simple path with the sum of weights greater than ‘K’ and ‘NO’ if there is no such path.
You do not need to print anything. It has already been taken care of. Just implement the given function.
2 ≤ V ≤ 10
1 ≤ E ≤ 20
1 ≤ K ≤ 100
Time limit: 1 second
The idea is to use Backtracking here. First, we start from the given source, explore all paths from the current vertex. We keep track of the current distance from the source. If the distance becomes more than ‘K’, we return true. If a path doesn’t produce more than ‘K’ distance, then, we backtrack.
Now the main task here is to decide that how can we make sure the path is simple and we don’t loop in a cycle? The idea is to keep track of current path vertices in an array. Whenever we add a vertex to a path, we check if it already exists or not in the current path. If it exists, we ignore the edge.
This can be implemented using the steps below:
4. Return ‘False’ if there are no adjacent edges that can provide a longer path length.
Sorted Doubly Linked List to Balanced BST
Longest Substring with K-Repeating Characters
Expression Add Operators
Gray Code Transformation
Count of Subsequences with Given Sum