Back to problems

Enumerate All Simple Directed Cycles

Algorithm · ByteDance · Hard

You are given a directed graph with n vertices labeled from 0 to n - 1, and a list edges of directed edges. Each edge is given as [u, v], meaning there is an edge from u to v. Return every distinct simple directed cycle in the graph. A simple directed cycle is a sequence of vertices v1, v2, ..., vk with k >= 1 such that all of the following hold: For each i from 1 to k - 1, the edge [vi, vi+1] exists. The edge [vk, v1] exists. The vertices v1, ..., vk are all distinct. A…

Checking your access…