dishes (each one is a single word, no duplicates), and the reviews are in the array reviews: each review is a sequence of words separated by single spaces.
The popularity of a dish is the number of reviews in which its name appears as a separate word. If a review names the same dish several times, that review still counts only once.
Return the dish names ordered by popularity, highest first. Dishes with equal popularity keep the order they have in dishes.dishes=["soup", "pie", "salad"], reviews=["pie pie pie", "soup and pie", "salads were cold"] → ['pie', 'soup', 'salad']
pie is mentioned in two reviews (repeats within one review count once), soup in one, salad in none: the word salads is not salad.
dishes=["tea", "cake", "jam"], reviews=["jam", "cake"] → ['cake', 'jam', 'tea']
cake and jam have one mention each and keep their order from dishes; tea is never mentioned, so it goes last.
dishes=["rice"], reviews=["more rice please"] → ['rice']
dishes[i] are distinctreviews[j] consists of lowercase English letters, digits, hyphens and spaces, with no leading or trailing spaces and no two spaces in a rowdishes=["soup", "pie", "salad"], reviews=["pie pie pie", "soup and pie", "salads were cold"]
['pie', 'soup', 'salad']
Run checks the first 3 tests in your browser. Submit checks all 49 tests on the server, hidden ones included.