- Published on
Google | L5 | Onsite
- Author
- Shared Anonymously
Input:
W = {"and", "not", "but", "jane", "jordan", "bob"}
L = {"qxuw", "xuo", "qeiopxu", "tyr", "uer", "tet"}
You are given list of words W which are encoded as list L in jumbled order. If you arrange words in L in order of words in W, it will be:
//L = {"xuo", "uer", "tyr", "qxuw", "qeiopxu", "tet"}
a is encoded to x
n is encoded to u
d - o
o - e
etc
So you have to find out this order where each char has a unique encoding and then decode the words written in L acc to this encoding
O/p: Decode the words in L to make sentence o/p
Example o/p in this scenario is: "jane and jordan but not bob"
There might be no ordering. Here, 3 letter words in W are "and", "not", "bob". So to solve the question, we try these words with all 3 letter words in L to see which matching is giving match for whole string. So sometimes there can be that none of the match can give match for whole string. Then you o/p null