Check Whether Release Notes Pin Down a Unique Version Order
Last updated: November 29, 2026
Quick Overview
Given n version ids and a list of sequences, each showing some versions in the order they were released, decide whether exactly one ordering of all n versions is consistent with every sequence, and return it if so.
0
0
0 solved
Given n version ids and a list of sequences, each showing some versions in the order they were released, decide whether exactly one ordering of all n versions is consistent with every sequence, and return it if so.
An onsite question that tests deeper understanding of topological sort: not just finding an order, but knowing when it is unique. The Google interviewer checks that you derive edges from adjacent pairs and that you watch the queue size during Kahn's algorithm.
What the Interviewer Expects
- Derive edges from consecutive elements of each sequence
- Run Kahn's algorithm
- Declare non-unique if the queue ever holds more than one node
- Detect cycles as inconsistent
- Return the unique order when it exists
Key Topics to Cover
How to Approach This
- Clarify input constraints and edge cases before writing code.
- Walk through your approach verbally and confirm with the interviewer before coding.
- Start with a brute force solution, then optimize. Mention time and space complexity.
- Test your solution with examples, including edge cases like empty input or duplicates.
- Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
- Why is it enough to use only adjacent pairs from each sequence?
- Return the number of valid orderings for small n.
- How would you report which extra pair would make the order unique?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice DSA ProblemsSample Answer
Requirements
- Input:
n(versions 1..n),seqslist of lists. - Output: the unique full order, or
Noneif zero or many orders are consistent. - Every version is assumed to appear in at least one sequence; val...
High-Level Design
Each sequence [a, b, c] asserts a < b < c. Only consecutive pairs are needed as edges, since the transitive ones follow. Build the DAG and run Kahn's algorithm. The topological order is unique exa...