Question
A tournament is a directed graph on n players (0..n-1) where, for every unordered pair {i, j}, exactly one directed edge exists; matches is the list of those edges, where [u, v] means u beat v. A full ranking is an ordering of all players where each player beat the next one in the ordering (a Hamiltonian path along the beat edges) -- one always exists in a tournament. Return the lexicographically smallest such ordering as a list of player ids. Constraints: 2 <= n <= 20.
lex_ranking(n: int, matches: list[list[int]]) → list[int][3,[[0,1],[1,2],[2,0]]]out[0,1,2]State your approach and its time/space complexity out loud before you optimize. Handle the edge cases (empty input, duplicates, overflow), and say why you chose this over the brute force. Green tests are the floor, not the grade.
Vibe coding: describe the solution in plain language (or narrate it) and the coach grades your approach. Generating runnable code from your description is coming next.