I need help finding a solution to count how many times a word appears in sentences.
Input:
k = 2
keywords = ["anacell", "cetracular", "betacellular"]
reviews = [
"Anacell provides the best services in the city",
"betacellular has awesome services",
"Best services provided by anacell, everyone should use anacell",
]
Output:
["anacell", "betacellular"]
Explanation:
"anacell" appears in 2 reviews and "betacellular" only appears in 1 review.
Input:
k = 2
keywords = ["anacell", "betacellular", "cetracular", "deltacellular", "eurocell"]
reviews = [
"I love anacell Best services; Best services provided by anacell",
"betacellular has great services",
"deltacellular provides much better services than betacellular",
"cetracular is worse than anacell",
"Betacellular is better than deltacellular.",
]
Output:
["betacellular", "anacell"]
Explanation:
"betacellular" appears in 3 reviews. "anacell" and "deltacellular" appear in 2 reviews, but "anacell" comes first alphabetically.
Using the keywords provided, I want to determine their frequencies in the reviews array and display the most frequently occurring keyword.