Sunday common C++ interview problem: Longest cycle in a graph.
Given a directed graph as std::vector<int>, where the value at index i represents the destination of an outgoing edge from i (-1 is used to represent no outgoing edges), determine the size of the longest cycle in the graph.
Solve it yourself: https://compiler-explorer.com/z/4P3Pv8r9M
Solution: https://compiler-explorer.com/z/vd1sdsjWq