Password From Ordering Hints
Reported by candidates from Rogo's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.
Rogo reported this one in September 2026, and the whole question hinges on a directed graph. Each hint is a chain of ordering constraints between characters, and you need one password that respects all of them. If you spot that in the first minute, the rest is bookkeeping. If you don't, you'll burn time on string tricks that go nowhere. It's a topological sort with a lexicographic tie-break and a cycle check. StealthCoder is the safety net if your mind goes blank mid-assessment, but the pattern is simple enough to own before you start.
The problem
Each string in hints lists distinct password characters in their required relative order. The password contains every distinct character that appears in any hint exactly once. Return the lexicographically smallest password consistent with every hint. Return the empty string when the hints contain a cycle and no valid password exists. Function deducePassword(hints: String[]) → String Examples Example 1 hints = ["wrt","wrf","er","ett","rftt"] return = "" Combining adjacent constraints yields the unique order wertf. Example 2 hints = ["ab","ba"] return = "" The two hints require both a before b and b before a. Constraints 1 <= hints.length <= 10000 Each hint contains 1 to 62 distinct letters or digits. At most 62 distinct characters appear overall.
Reported by candidates. Source: FastPrep
Pattern and pitfall
Treat every distinct character as a node. For each hint, add an edge between each adjacent pair, since adjacent pairs imply the rest by transitivity. Track indegree, then run Kahn's algorithm. To get the lexicographically smallest result, pull from a min-heap, or just scan the at most 62 characters each round and pick the smallest with indegree zero. If the output length is less than the node count, there's a cycle, so return the empty string. Pitfalls: forgetting characters that appear in only one hint, adding duplicate edges and inflating indegree, and using plain BFS order instead of the smallest available. Note the example 1 text says the order is wertf but the stated return is empty, so trust the rules, not that prose. StealthCoder can hedge the live OA if you blank on the heap detail.
The honest play: practice the pattern, and have StealthCoder ready for the one you didn't see coming.
You can drill Password From Ordering Hints cold, or you can hedge it. StealthCoder runs invisibly during screen share and surfaces a working solution in under 2 seconds. The proctor sees the IDE. They don't see what's behind it. Built for the candidate who saw this exact problem leak two days before his OA and wondered if anyone had a play.
Get StealthCoderYou've seen the question.
Make sure you actually pass Rogo's OA.
Rogo reuses patterns across OAs. Built for the candidate who saw this exact problem leak two days before his OA and wondered if anyone had a play. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Password From Ordering Hints FAQ
What's the trick in Password From Ordering Hints?+
Build a directed graph from adjacent characters in each hint, then run a topological sort. Use a min-heap for the zero-indegree set so the result is lexicographically smallest. If you can't place every character, there's a cycle and you return an empty string.
How hard is this really?+
Medium. The graph idea is the only hurdle. With at most 62 distinct characters, performance isn't a concern. The mistakes come from duplicate edges, missing isolated characters, and forgetting the cycle check at the end.
Do I need edges for every pair in a hint?+
No. Adjacent pairs are enough because ordering is transitive. Adding all pairs works but creates redundant edges. If you do add duplicates, use a set per node so indegree counts stay correct.
How do I get the lexicographically smallest answer?+
Each round, among characters with indegree zero, pick the smallest. A min-heap does this cleanly. With only 62 nodes, sorting or scanning the available set each step also works and is easy to write.
How do I prepare for this in 48 hours?+
Write Kahn's algorithm from memory twice, once with a queue and once with a heap. Practice the cycle check by comparing output length to node count. Then test your code on a two-hint contradiction like ab and ba.