Infer Character Ranking From a Locale-Sorted Driver Name Directory

Last updated: November 29, 2026

Quick Overview

A driver directory in a new market is sorted by an unknown alphabet; given the list of names in sorted order, return one ordering of all characters consistent with it, or an empty string if the list is inconsistent.

Uber
Coding & Algorithms
Software Engineer
Uber
November 29, 2026
Software Engineer
Onsite
Coding & Algorithms
Hard

0

0

0 solved


A driver directory in a new market is sorted by an unknown alphabet; given the list of names in sorted order, return one ordering of all characters consistent with it, or an empty string if the list is inconsistent.

Uber launches in markets with many scripts and collation rules, and an internal tool might need to infer the collation used by an exported list. The onsite interviewer checks that you extract only the first differing character between adjacent names, catch the prefix trap, and finish with a topological sort.

What the Interviewer Expects
  • Compare only adjacent names, and only their first differing character
  • Detect the invalid case where a longer name precedes its own prefix
  • Include every character, even ones with no ordering constraint
  • Topologically sort and detect cycles
  • Explain why non-adjacent comparisons add nothing
Key Topics to Cover
topological sort
graph construction
string comparison
cycle detection
How to Approach This
  1. Clarify input constraints and edge cases before writing code.
  2. Walk through your approach verbally and confirm with the interviewer before coding.
  3. Start with a brute force solution, then optimize. Mention time and space complexity.
  4. Test your solution with examples, including edge cases like empty input or duplicates.
  5. Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
  • How would you tell whether the inferred order is unique?
  • What if a small number of names were sorted incorrectly by a buggy export?
  • How does this change for multi-character collation units like 'ch' in some languages?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Practice DSA Problems
Sample Answer
Requirements
  • Input: list of lowercase strings names sorted by an unknown character order.
  • Output: string containing every character that appears, in an order consistent with the list; '' if impossible....
High-Level Design

Adjacent names give at most one constraint: at the first index where they differ, the earlier name's character comes first. Later characters tell us nothing, and comparing non-adjacent names is implie...


Submit Your Answer
Markdown supported