Flipkart Coding Question – Solved

11 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

| You are given a board of size M Γ— N where each cell can be either empty ('O') o… |
| Undirected Coloured Graph Shortest Path You are given an undirected weight… |
| Village Voyage A computer game "Village Voyage" has N villages (labeled 1 to… |
| Academic Decathlon Students are being selected for an academic decathlon tea… |
| Sum of Arrays Given two arrays each of length n, arr1 and arr2, in one opera… |
| Count Swaps During Custom Sorting Analyze the efficiency of the following so… |