Company: Josh technology_15july
Difficulty: medium
Analyze Query Similarity Problem Description You're part of a team building a new query suggestion feature for a search engine. When a user types a sequence of queries, your system groups related queries together so it can recommend similar queries later. To evaluate how well the grouping works, your team tests what happens when a single query is removed from the list. After removing each query, the system checks neighbouring queries to see how similar they still are. Two queries are considered similar if they share the same starting characters . The number of matching starting characters measures the similarity score. Your goal is to implement a function analyzeQuerySimilarity that find the highest similarity scores among any pair of adjacent queries that remain, for each possible single removal . If no matching starting characters exist between any pair of adjacent queries, the similarity score for that removal is 0. Examples Example 1: Input: ["flower", "flow", "flight"] Output: [2,