Flipkart Coding Question β Solved
1. Simple Text Queries
In this challenge, you will be given an array of sentences and an array of queries. Determine which
sentences contain all of the words of a query. If no sentence contains all of the words, the answer to
that query is [-1].
Example:
sentences = ['bob and alice like to text each other', 'bob does not like to ski but does not like to fall',
'Alice likes to ski']
queries = ['bob alice', 'alice', 'like', 'non occurrence']
The results of the queries are:
0. sentences[0] -> [0]
1. sentences[0] -> [0]
2. sentences[0], sentences[1], sentences[1] -> [0, 1, 1]
3. none match -> [-1]
Return a 2-dimensional integer array: [[0], [0], [0, 1, 1], [-1]].
Note: The word "like" in queries[2] does not match "likes" in sentences[2]. The word "alice" does not match
"alice" in sentence[2]. Matches must be exact.
After each query has been processed, add an array of indices of the matching sentences to the answer.