Dropbox has tasked you with gathering some qualitative metrics regarding a simple text search auto-complete feature. You'll be given a set of documents, each having a title and a body of text.
Every word in the documents can be assigned a numeric score. The score is defined as follows:
Note that the scores should be computed across all documents.
For example, given two documents
| Title | Body | |
|---|---|---|
| Document A | ANIMALS | ANT ANTELOPE CAMEL CAT DOG |
| Document B | DOG FACTS | FURRY FURRY LOYAL |
You'll then be given a set of user queries, each a string with no whitespace. For each query, compute the highest score among all the words that could be auto-completed from it. For instance, among the set of words above, the query 'AN' could be auto-completed into ANIMALS, ANT, and ANTELOPE. If no such words exist, the score is 0.
For example, given these following queries:
You can assume text and queries are comprised of A-Z characters. In documents, words are separated by a space; there is no other whitespace.
public static List<Integer> getAutocompleteScores(List<String> documentTitles, List<String> documentBodies, List<String> queries) {
// todo
}Constraints