Marge is rather concerned about the hoodlums that her son has been spending time with. Aside from all of the time spent at the arcade, they communicate with each other through encrypted messages. As a concerned parent, Marge wants to discover what the boys are talking about.
Marge knows parts of the boys' code library, given as a String[]. Each element is formatted as "C SEQUENCE" (quotes for clarity), where C is an uppercase letter, SEQUENCE consists of only '-' and '.' characters, and exactly one space separates the two. When writing their message, the boys will replace C with SEQUENCE, separating multiple letters with spaces. So, if O is represented as "---" and S is represented as "...", then the message "SOS" can be encoded as "... --- ...".
Marge has recovered an encoded message that she would like to decode. Unfortunately, she does not have a full copy of the library, so there may be some SEQUENCEs that do not correspond to any entries in the library; if this happens, you are to replace it with a '?' (Marge is a smart mom, and might be able to figure out what the word is with only partial information). You are to return a String containing the decoded message.
|