Finding the top items of an array with highest frequency
Anonymous User
255

I am struggling to find an idea for sovling this problem:
We have an array of pizza toppings like this: ( In real world think we have a data of all the topping combinations that people have ordered on their pizzas so example:
[
["pepperoni"],
["pepperoni" , "mushroom"],
["olives", "mushroom", ]
["pepperoni"],
["pepperoni" , "mushroom"],
["pepperoni" , "mushroom"]
]

Now the goal is to sort this by frequncy of their popularity so for example three people have done ["pepperoni" , "mushroom"] on their pizzas so that one is the most popular ... then the ["pepperoni"] is the second most popular.

How do you suggest I can solve this?

Comments (3)