I was asked this question in Flipkart virtual onsite.
Can anyone suggest a optimal approach for it ?
Question
We have to arrange items in such a way that, items with 3 or more similar metadata are grouped together.
We are given 25,000 items, each item has some feature information about it (basically item metadata) like type,weight,industry,.... and so on. The metadata may or maynot have similarity across items.
Certain items can have 4 features metadata about them, some can have even 10-12 features.

All of this information is present in python dictionary, in memory.
warehouse_items = {"Item1":[f1,f2,f3,...],
"Item2":[f1,f2,f3],
....
}Your task is to come up with a data structure such that, that arranges the data in such way that,
given input an [Item], it lists out all the items that share 3 or more similar Metadata with the given item.
As we have to find grouping for 25,000 items. So, we can assume 25,000 lookup operations for 25,000 items.
You are free to use any DB or datastructure.
My Approach
Create nested dictionaries.
This data structure can have n level of nested dictionaries.
Outer keys will contain combined list of all feature set of items that share 1 or more feature
and as we go deep in nested, keys get more and more specific containing combined metadata of items.
So, suppose if my target Item has weight=200kg,from outer dictionary we will select only the key that has
200Kg present in it.
In this way if we have suppose if we have 200 items, out of which 50 items doesn't have
200kg in any of it, we will be now dealing with only 150 items, in next iteration.
So this way, we will just arrange the data once and then multiple operations can be performed more efficiently on it.

I feel there can be better approaches than this, can you suggest any that might perform better.