Back to problems

Check and infer custom alphabet

Algorithm · Meta · Hard

An application ranks text with a letter ordering of its own instead of the usual a–z collation. That ranking is handed to you as a string, order, which contains each of the 26 lowercase letters exactly once; whenever one letter sits earlier in order than another, the earlier one counts as smaller. Comparing two words proceeds position by position. At the very first index where their characters disagree, the word holding the earlier-ranked character is the smaller one. When…

Checking your access…