All Paths from Source Lead to Destination
Difficulty: Medium
Category: DSA
Topics: Graph, Topological Sort
Asked at: Bloomberg
You are given a directed graph with `n` nodes labeled from `0` to `n - 1`, represented by a list of directed edges `edges`, where each `edges[i] = [ui, vi]` indicates a directed edge from node `ui` to node `vi`. You are also given two integers, `source` and `destination`.
Return _true_ if and only if **every possible path** starting from `source` eventually leads to `destination`. Specifically, this means:
- At least one path exists from `source` to `destination`.
- If a path leads to a node with no outgoing edges, that node must be `destination`.
- The graph does not contain cycles that can be reached from `source` (i.e., no path from `source` can enter a cycle).
Otherwise, return _false_.
**Constraints:**
- `1 <= n <= 10^4`
- `0 <= edges.length <= 10^4`
- `0 <= ui, vi, source, destination < n`