There is shop of items, users buying them.
Find k most popular items
Implement datastructure to hold items and 2 methods :
addItem(Item n)
getMostPopular(int k)
what is complexity of each one.
class Item{
String id ;
String name;
}
class DataStructure{
void addItem(Item n) {
//implement this
}
ArrayList<Item> getMostPopular(int k){
//implement this
}
}