Find Eventual Safe States
Given a directed graph as an adjacency list `graph` with `n` nodes numbered `0` to `n - 1`, implement `solve(graph)`. A node is eventually safe if every path starting from it ends at a terminal node with no outgoing edges. Equivalently, no path from the node enters a cycle. Return all eventually safe node labels in ascending order.