A school canteen asked pupils for their favourite lunch and wants to know which answer was the most popular. If several answers are tied for the top, the canteen wants all of them; picking one would hide the tie. And if there are at least two different answers and every one of them was given the same number of times, no answer stands out, so the report is empty.
Write favourites(answers) that returns the list of the most common answers, in the order in which each first appears in answers. The answers may be strings or numbers.
Examples
Input: answers = ["pasta", "curry", "pasta", "soup", "curry", "pasta"]
Output: ["pasta"]
Input: answers = ["soup", "curry", "pasta", "curry", "soup"]
Output: ["soup", "curry"]
Explanation: soup and curry were each chosen twice; soup appeared first.
Input: answers = ["soup", "curry", "curry", "soup"]
Output: []
Explanation: both answers were given twice, so none stands out.
Constraints
0 <= len(answers) <= 10**5(an empty survey gives[])- a survey in which only one answer was ever given returns that answer
Goals
- Count how often each value occurs with a dictionary
- Report every value tied for the highest count, not just one of them
- Recognise data where no value stands out