Search⌘ K
AI Features

Longest Cycle in a Graph

Longest Cycle in a Graph gives each node at most one outgoing edge and asks you to return the length of the longest directed cycle, or -1 if none exists.

Statement

You are given a directed graph with n nodes, labeled from 0 to n - 1. Each node in the graph has at most ...