Geeksforgeeks

Error

×

Leaderboard

Showing:

Handle | Score |
---|---|

@Ibrahim Nash | 5761 |

@blackshadows | 5701 |

@akhayrutdinov | 5111 |

@mb1973 | 4989 |

@Quandray | 4944 |

@saiujwal13083 | 4506 |

@sanjay05 | 3762 |

@marius_valentin_dragoi | 3516 |

@sushant_a | 3459 |

@verma_ji | 3341 |

@KshamaGupta | 3318 |

Complete Leaderboard | |

Handle | Score |

@aroranayan999 | 938 |

@bt8816103042 | 739 |

@SHOAIBVIJAPURE | 428 |

@codeantik | 412 |

@SherlockHolmes3 | 407 |

@neverevergiveup | 348 |

@mahlawatep | 347 |

@shalinibhataniya1097 | 343 |

@murarry3625 | 333 |

@saiujwal13083 | 326 |

@rohitanand | 314 |

Complete Leaderboard |

Given a graph, a source vertex in the graph, and a number k, find if there is a simple path, of path length **greater than or equal to k**,(without any cycle) starting from a given source and ending at any other vertex.

Source vertex should always be 0.

**Example 1:**

**Input**:
V = 4 , E = 3 and K = 8
A[] = [0, 1, 5, 1, 2, 1, 2, 3, 1]
**Output:** 0
**Explanation**:
There exists no path which has a distance
of 8.

**Example 2:**

**Input:**
V = 9, E = 14 and K = 60
A[] = [0, 1, 4, 0, 7, 8, 1, 2, 8, 1, 7,
11, 2, 3, 7, 2, 5, 4, 2, 8, 2, 3, 4, 9,
3, 5, 14, 4, 5, 10, 5, 6, 2, 6, 7, 1, 6,
8, 6, 7, 8, 7]
**Output: **0
**Explanation:
**

**Your Task: **

You don't need to read input or print anything. Your task is to complete the function **pathMoreThanK()** which takes the integer V, Edges E, an integer K and Array A which is having (Source, Destination, Weight) as input parameters and returns 1 if the path of at least k distance exists, else returns 0.

**Expected Time Complexity:** O(N!)

**Expected Auxiliary Space:** O(N)

**Constraints:**

2 ≤ V ≤ 5

1 ≤ E ≤ 20

1 ≤ K ≤ 100

Login to report an issue on this page.

We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?

Yes
Path of greater than equal to k length

...