Untitled

 avatar
unknown
plain_text
2 years ago
495 B
4
Indexable
Got the following problem in Uber interview. Please help me to solve this:

Given a dictionary of words, where each list represents the set of words which are synonyms and a list of Queries. Find out the distinct number of queries.

A query will be duplicate if it has
(x,y) ->

(x, syn(y))
(syn(x), y)
(syn(x), syn(y))
Example:

dict = [['a', 'b', 'c', 'd'],
['p', 'q', 'r', 's'],
['u', 'v', 'w']
['x', 'c', 'y', 'z']]

Queries: (a,b), (p,q), (a,p), (a,q), (u,a), (y,a)
Ans: 4
Editor is loading...