Algorithm · ByteDance · Medium
You are given a directed graph with n nodes labelled 0 through n - 1, a source node s, and a destination node t. Perform two tasks: List every simple directed path from s to t. A simple path is a sequence of distinct nodes where each consecutive pair is a directed edge. List every simple directed cycle in the graph. A simple directed cycle is a closed walk where only the start node appears twice (at the beginning and end). Two cycles that differ only by a cyclic rotation are…