I have a question about implementing a data structure (with algorithm) that has these features:
There are too many places (like stores), and each place can store too many items, I want to store items in the places. The point is we need to have optimized insertion (or deletion) and optimized search feature.
Search can be done based on places (return items in the place) or base on items (return places that have the item)
I thought to use a hashmap for this, and use places ID as the key and store items as a collection (again a hashmap with item id for both key and value).
So based on this, the insertion of each item or place would be O(1) but get or remove of place will be O(n) and for item it will be O(n*k)! (assume we have "n" places and "k" items - I hope this is the correct calculation).
Is there any better data structure or algorithm for this problem?