Note that there are some explanatory texts on larger screens.

plurals
  1. POQuestion from Interview, Retrieve alphabetic order from dictionary
    primarykey
    data
    text
    <p>My girlfriend got this question in an interview, and I liked it so much I thought I'd share it... Write an algorithm that receives a dictionary (Array of words). The array is sorted lexicographically, but the abc order can be anything. For example, it could be z, y, x, .., c, b, a. Or it could be completely messed up: d, g, w, y, ... It doesn't even need to include all the abc letters, and finally it doesn't have to be letters at all. It could be any symbols that form a string. For example it could be made up of 5, α, !, @, θ... You get the idea. It's up to your algorithm to discover what the letters are (easy part).</p> <p>The algorithm should return the correct lexicographic order of the symbols.</p> <p>Note/Things to consider: 1. For a given dictionary, can you always discover the full order of all the letters? Consider a dictionary that only has 1 word, with more than 1 symbol... 2. You CANNOT assume that the dictionary is without error. The algorithm should determine if the dictionary contains contradictions and output that there is an error. 3. HINT: Think of a good data structure to represent the relations you discover between symbols. This should make the problem much easier.</p> <p>I'll post my solution probably tomorrow. By no means do I claim that it's the most efficient one. I want to see other people''s thoughts first. Hope you enjoy the question</p> <p>P.S. I think the best format to post solutions is with pseudo code, but I leave this to your consideration</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload