Flipkart Coding Question – Solved

6 Live
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.

Asked in: Flipkart

Image of the Question

Question Image

All Testcases Passed βœ”



Passcode Image

Solution


Please login to view the solution


Related Questions

| Given an n x m grid, where rows are numbered from 7 to n and columns from 1 to … |
| There are 'N' coders standing in a line, where i denotes the ith position of a … |
| A birthday party was attended by N number of kids, and each kid was given a uni… |
| Given a matrix of size m * n, where m denotes the number of rows (starting with… |
| A traveler is traveling from the city of Zeta to Omega. He starts with X amount… |
| As an operations engineer at Amazon, you are responsible for organizing the dis… |