Company: Josh technology_15july
Difficulty: medium
Analyze Query Similarity Problem Description You are building a query-suggestion feature for a search engine. A user has typed a sequence of queries, and the system groups queries that look related so it can recommend them later. To test how stable the grouping is, the team removes exactly one query from the sequence and then checks how similar the queries that end up next to each other still are. Two queries are similar when they begin with the same characters. The similarity score of a pair of queries is the number of characters they share at the very start: compare them character by character from position 1 and stop at the first position where they differ, or when the shorter query ends. That count is the score. For example, flower and flow score 4, flow and flight score 2, and dog and car score 0. For every index i , remove queries[i] from the sequence. The remaining queries keep their original relative order and close the gap, so the query just before the removed one and the quer